sgoswami-systango / django-cron

Automatically exported from code.google.com/p/django-cron
MIT License
0 stars 0 forks source link

Bug when cron period > 1 day #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. set a cron to be run once a day for example
2. wait ...
3. Nothing will happen :(

The bug is in __init__.py, line 26:

  if (datetime.now() - job.last_run).seconds > job.run_frequency:

timedelta.seconds doesn't convert a timedelta into seconds, bu returns the
seconds part of the timedelta, between 0 and 86399 inclusive
(http://docs.python.org/library/datetime.html#datetime-timedelta ). The
right syntax would be:

   delta = datetime.now() - job.last_run
   if delta.seconds + 86400*delta.days > job.run_frequency:

Thanks in advance,

Johan

Original issue reported on code.google.com by joha...@wanadoo.fr on 30 Sep 2009 at 7:34

GoogleCodeExporter commented 9 years ago
Oops, made a mistake, the error occurs in base.py:101

Original comment by joha...@wanadoo.fr on 5 Oct 2009 at 8:58

GoogleCodeExporter commented 9 years ago
Thanks for the fix -> just checked it in

Original comment by Jim.mixt...@gmail.com on 28 Oct 2009 at 2:23