celery/celery — pull request #949 by gugu (2012-08-29 11:04:59+00:00)
Title: Fix of bug when celery stops processing frequent tasks and runs daily tasks every minute

If celerybeat user is in the eastern part of the world (for example, in the Moscow), two bugs appear:

First:

If task in crontab runs at Wednesday 01:00, and last_run_at is Wednesday 01:00 (it is Tuesday 21:00 in UTC), `remaining_estimate` in celerybeat creates

relativedelta(weekday=(next_day - 1) % 7, hour=next_hour, minute=next_minute)

But next_day and dow_num is extracted from last_run_at it UTC. dow_num is Tuesday, next_day is Wednesday. It is equal to "Wednesday, 01:00:00". After that it compares this date with current date in local time: "Wednesday, 01:00:01" and returns negative interval. Task is scheduled again and again from 0:00 to 04:00.

Second:

If task runs every 5 minutes, at Wednesday 00:55 in MSK (it is 20:55 GMT) `execute_this_hour` becomes False, but `execute_today` is True (it is 20 hours). And relativedelta becomes "20:00:00", and when added to last_run_at in local timezone becomes Wednesday, 20:00:00. And small tasks stop running

I fixed that. But countries with strange timezones (+3:30 or +6:45) still can find these bugs