开发者

How does django-cron work?

开发者 https://www.devze.com 2023-03-15 19:04 出处:网络
A normal approach to cron jobs with a django site would be to use cron to run custom management commands periodically.

A normal approach to cron jobs with a django site would be to use cron to run custom management commands periodically.

But I found this http://code.google.com/p/django-cron/

How does it work, without needing cron? What invokes it to poll?

If it just sets up an address for an http request to hit periodically, what if the job takes开发者_StackOverflow中文版 a long time, won't the server time out?


It continually fires off a Timer thread, whose whole purpose is to wait a defined amount of time (the polling frequency you set in settings.py) and then run the execute on the django-cron queue again.


It depends on Django being a long-lived process, which if configured correctly it is. It runs a thread to check every 5 minutes (by default) to see if there are any jobs that need to be run, and if so runs them.

0

精彩评论

暂无评论...
验证码 换一张
取 消