Re: Django Celery throwing runtime warnings for naive times

2014-04-28 Thread John DeRosa
I suggest you file a ticket in the celery project 
(https://github.com/celery/celery/issues), or ask for help on the #celery IRC 
channel. (See 
http://celery.readthedocs.org/en/latest/getting-started/resources.html for 
"help" resources...) They'd be more profitable avenues for you, given the code 
path that's in the stack dump.

John

On Apr 28, 2014, at 3:33 AM, heidi  wrote:

> 
> 
> 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 

Django Celery throwing runtime warnings for naive times

2014-04-28 Thread heidi

  
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 _reschedulesreturn 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_whilereturn 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_updatereturn filtered._update(values) > 0
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 
507, in _updatereturn 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_valueRuntimeWarning)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?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7aebb9f9-c627-4f6f-ac20-25324c26a3b1%40googlegroups.com.
For more options, visit