python - 请教一下大家,在django或者其他的项目中做定时任务?
PHPz
PHPz 2017-04-18 09:23:53
0
8
403
有时候,需要在项目中做一些定时的任务,例如:我需要每隔几分钟去访问一个接口,然后根据返回值,做后续操作。

请教下,如何来实现?(PS:如果是用系统的crontab就不要说了。)

目前google了一种方法是使用celery。请加下大家,是否是条长期可行之路。
PHPz
PHPz

学习是最好的投资!

reply all(8)
洪涛

If you use Django’s own server to run your website, you can use django-celery. But if it is a website running with uWSGI, it is best to use uWSGI's signal for scheduled tasks. Other scheduled tasks are likely to be killed by uWSGI because they occupy the thread for a long time. I have worked on a website before that needs to crawl data on a scheduled basis. After trying several solutions, I finally used uWSGI's signal, which is more stable.

PHPzhong

django-celery can meet your requirements

阿神

You can also use independent Celery, just use Celery's beat for scheduled tasks.

黄舟

You can use crontab directly. If you want to better manage the scheduled process (such as using the supervisord tool), you can use celery scheduled tasks.
Here is a question: Flask configures celery scheduled tasks

Ty80

Someone made a Django module: django_crontab

小葫芦

For scheduled tasks, I usually use huey. I have used crontab before, but the virtual environment on the server cannot be activated using the script. I have been working on it for a long time without solving it. Then I found huey, which is actually similar to the django project. An app is installed that can implement multi-threading, periodicity and other functions.

阿神

Why not use crontab? crontab is the most stable.

左手右手慢动作

You can use Scheduler, because the content is a bit more, if you need examples, you can contact me.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template