You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Django Q to send emails on an hourly basis, and after the job runs, the "next_run" setting is changed to 2 hours prior to the run just complete, so the next minute the scheduler checks for new jobs if finds that same job, and reruns it, and again schedules it for 2 hours further back in history. Here's a printout taken over several job runs.
run 1. core.tasks.send_mail 2016-01-04 22:57:23.159561
run 2. core.tasks.send_mail 2016-01-04 18:57:23.159561
run 3. core.tasks.send_mail 2016-01-04 10:57:23.159561
run 4. core.tasks.send_mail 2016-01-03 02:57:23.159561
run 5. core.tasks.send_mail 2016-01-02 14:57:23.159561
And I suppose one gets the idea. If I switch the schedule_type to DAILY, then the next_run advances as expected.
Now, change schedule_type = "D":
run 1. core.tasks.send_mail D 2016-01-01 17:57:23.159561
run 2. core.tasks.send_mail D 2016-01-02 12:57:23.159561
run 3. core.tasks.send_mail D 2016-01-03 12:57:23.159561
run 4. core.tasks.send_mail D 2016-01-04 12:57:23.159561
run 5. core.tasks.send_mail D 2016-01-05 12:57:23.159561
And then by run 5 it's fully caught up and stops running every minute. Here's my code, which I'm calling in apps.py.
class MyAppCore(AppConfig):
name = 'core'
verbose_name = 'MyApp Core'
def ready(self):
send = 'Cron: send_mail'
if not Schedule.objects.filter(name=send).exists():
Schedule.objects.create(
name=send,
func='core.tasks.send_mail',
schedule_type=Schedule.HOURLY,
)
The task is just a wrapper around the management command:
Ok, egg on my face. I had the TimeZone problem in my settings file. Finally found the problem after a some careful placing of print statements showed that the next_run time changed between saving & extracting from the db. TADA. Gah!
I'm using Django Q to send emails on an hourly basis, and after the job runs, the "next_run" setting is changed to 2 hours prior to the run just complete, so the next minute the scheduler checks for new jobs if finds that same job, and reruns it, and again schedules it for 2 hours further back in history. Here's a printout taken over several job runs.
run 1. core.tasks.send_mail 2016-01-04 22:57:23.159561
run 2. core.tasks.send_mail 2016-01-04 18:57:23.159561
run 3. core.tasks.send_mail 2016-01-04 10:57:23.159561
run 4. core.tasks.send_mail 2016-01-03 02:57:23.159561
run 5. core.tasks.send_mail 2016-01-02 14:57:23.159561
And I suppose one gets the idea. If I switch the schedule_type to DAILY, then the next_run advances as expected.
Now, change schedule_type = "D":
run 1. core.tasks.send_mail D 2016-01-01 17:57:23.159561
run 2. core.tasks.send_mail D 2016-01-02 12:57:23.159561
run 3. core.tasks.send_mail D 2016-01-03 12:57:23.159561
run 4. core.tasks.send_mail D 2016-01-04 12:57:23.159561
run 5. core.tasks.send_mail D 2016-01-05 12:57:23.159561
And then by run 5 it's fully caught up and stops running every minute. Here's my code, which I'm calling in apps.py.
The task is just a wrapper around the management command:
The text was updated successfully, but these errors were encountered: