I run an online game with Django 1.6 and Celery 3.1.11. Kombu is 3.0.15.
Recently I had problems with Celery and DST, so I decided to run the whole site on UTC and save myself the bother of worrying about timezones.
The relevant parts of my settings.py:
TIME_ZONE = 'UTC' USE_TZ = True .... CELERY_ENABLE_UTC = True CELERY_TIMEZONE = 'UTC'
Now, whenever I send any delayed task, I see a bunch of RuntimeWarnings that complain about naive datetimes. I went into my settings.py and turned this into an exception, and this is the traceback that resulted:
[2014-04-18 15:03:49,748: INFO/MainProcess] Received task: sometask[sometaskid] eta:[2014-04-19 00:33:32.410032+00:00] [2014-04-18 15:03:50,130: ERROR/MainProcess] Error in timer: RuntimeWarning(u'DateTimeField TaskState.eta received a naive datetime (2014-04-18 17:50:19.547046) while time zone support is active.',) Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 171, in apply_entry entry() File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 64, in __call__ return self.fun(*self.args, **self.kwargs) File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 132, in _reschedules return fun(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", line 73, in capture self.state.freeze_while(self.shutter, clear_after=self.clear_after) File "/usr/local/lib/python2.7/dist-packages/celery/events/state.py", line 421, in freeze_while return fun(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", line 70, in shutter self.on_shutter(self.state) File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 145, in on_shutter _handle_tasks() File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 139, in _handle_tasks self.handle_task(task) File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 105, in handle_task task_id=uuid, defaults=defaults) File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 128, in update_task obj.save() File "/usr/local/lib/python2.7/dist-packages/djcelery/models.py", line 358, in save super(TaskState, self).save(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 545, in save force_update=force_update, update_fields=update_fields) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 573, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 635, in _save_table forced_update) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 679, in _do_update return filtered._update(values) > 0 File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 507, in _update return query.get_compiler(self.db).execute_sql(None) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 975, in execute_sql cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 771, in execute_sql sql, params = self.as_sql() File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 940, in as_sql val = field.get_db_prep_save(val, connection=self.connection) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 353, in get_db_prep_save prepared=False) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 914, in get_db_prep_value value = self.get_prep_value(value) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 906, in get_prep_value RuntimeWarning) RuntimeWarning: DateTimeField TaskState.eta received a naive datetime (2014-04-18 17:50:19.547046) while time zone support is active.
As you can see, none of the traceback is due to my code, so I do not know how to proceed. I could merely leave the warnings in (if I recall correctly, Celery defaults time offsets to the CELERY_TIMEZONE
in settings.py, and this is what I want anyway) but my OCD is screaming out at me to get this fixed. Plus, I can't ctrl-F to find any warning that are due to my code.
Any advice?
No comments:
Post a Comment