Celery and Duplicate Tasks

140 views
Skip to first unread message

Shapath Neupane

unread,
Oct 10, 2015, 11:33:06 PM10/10/15
to Django users
I'm using celery as a queue to fetch extra details on the model I save. So when I user inputs a link, it goes to Embedly and fetches thumbnail, title and extra stuff.

However when I do that Celery goes into an infinite loop 






Celery is going into this infinite loop when I'm using Redis, I also tried RabitMQ but the same problem.


Thanks,
Shap.

Rakan Alhneiti

unread,
Oct 11, 2015, 9:31:46 AM10/11/15
to Django users
It looks like if not self.id is not evaluating to True which is why the task is being executing multiple times. Looking at your code, it looks like using the post_save signal by django is better because at that point you have access to the ID which you can pass to the celery task rather than passing the key.


If you also look at the documentation, you can figure out if it's a new record or not using the "created" flag which gets passed as a param to your signal handler.

Shapath Neupane

unread,
Oct 11, 2015, 10:13:35 AM10/11/15
to Django users
I get the same results even if I use post_save signals. I was using signals before.

Shapath Neupane

unread,
Oct 11, 2015, 10:42:28 AM10/11/15
to Django users
This only happens when I save a model instance, if I just get tasks only run the times it has been initiated. With Save I go into a forever loop.

Tried, signals, and direct save both.

On Sunday, October 11, 2015 at 7:16:46 PM UTC+5:45, Rakan Alhneiti wrote:

Shapath Neupane

unread,
Oct 11, 2015, 10:54:34 AM10/11/15
to Django users
Don't worry about it, I got it working, Had a stupid Model Save Loop Going On


On Sunday, October 11, 2015 at 7:16:46 PM UTC+5:45, Rakan Alhneiti wrote:
Reply all
Reply to author
Forward
0 new messages