Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django model doesn't get saved to database inside Celery Task

I've hit a really nasty situation. I have the following setup. I have a django model representing an FSM with a django FSM field

I have a celery task that sends out an email and then advances the state of the main objects FSM. From the celery task's perspective, the object "seems" to be saved. But from the main django process' perspective, the object isn't being updated. The strange thing is that ancillary objects are being saved properly to the DB, and later accessible from the main django process.

I explicitly call .save() on the object from the Celery task, and the date_last_modified = models.DateTimeField(auto_now=True, null=True) field has a later timestamp in the Celery task than the main thread, although I'm not sure if that's an indication of anything, i.e. it may have been updated but the update has not been flushed out to the DB.

I'm using django 1.5.1, postgresql 9.3.0, celery v3.1.0, Redis 2.6.10

Running Celery like so $ celery -A tracking worker -E -B -l info

Any ideas of why this may be happening would be greatly appreciated

like image 952
Andres Avatar asked Dec 20 '13 05:12

Andres


1 Answers

Are you re-getting the object after the save? I.e. not just looking at the instance you got before the save?

like image 142
synotna Avatar answered Nov 14 '22 23:11

synotna