views:

22

answers:

1

I have a task that runs in a celerybeat instance. When that talk is executed, it sometimes modifies a model object, which should fire off a post/pre_save signal, but it doesn't. The signal is not happening. I imagine this is due to django's signals being synchronous while celery is doing it's thing on a different server in a different thread in a different universe. Is there a simple way to still get those signals to fire while they're being ran in celery?

A: 

Django signals are local, which means that the signal handler must be registered in the worker as well.

If your signal handler is connected in e.g. models.py, then you need to import that in tasks.py to make sure it's also connected in the worker.

Alternatively you can specify additional modules the worker should import using the CELERY_IMPORTS setting:

CELERY_IMPORTS = ("myapp.handlers", )

or the -I argument to celeryd.

$ python manage.py celeryd -I myapp.handlers
asksol