Tivix / django-cron

Write cron business logic as a Python class and let this app do the rest! It enables Django projects to schedule cron tasks, tracks their success / failures, manages contention (via a cache) etc. Basically takes care of all the boring work for you :-)
www.tivix.com
MIT License
900 stars 193 forks source link

Intermittent exceptions #126

Closed agronick closed 6 years ago

agronick commented 7 years ago

We run a lot of jobs. Occasionally I'll get an exception that looks like this:

  File "/var/lib/wwwrun/.virtualenvs/supportlink/lib/python3.4/site-packages/django_cron/__init__.py", line 210, in run
    with self.lock_class(cron_job_class, self.silent):
  File "/var/lib/wwwrun/.virtualenvs/supportlink/lib/python3.4/site-packages/django_cron/backends/lock/base.py", line 60, in __enter__
    raise self.LockFailedException(self.lock_failed_message())
  File "/var/lib/wwwrun/.virtualenvs/supportlink/lib/python3.4/site-packages/django_cron/backends/lock/cache.py", line 47, in lock_failed_message
    started = self.get_running_lock_date()
  File "/var/lib/wwwrun/.virtualenvs/supportlink/lib/python3.4/site-packages/django_cron/backends/lock/cache.py", line 90, in get_running_lock_date
    if not timezone.is_aware(date):
  File "/var/lib/wwwrun/.virtualenvs/supportlink/lib/python3.4/site-packages/django/utils/timezone.py", line 261, in is_aware
    return value.utcoffset() is not None
AttributeError: 'NoneType' object has no attribute 'utcoffset'

get_running_lock_date does not check if the cache returned None.

maxim-kht commented 6 years ago

Duplicate of https://github.com/Tivix/django-cron/issues/78