I have a task that runs in a Celerybeat instance. When that task 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?
Asked
Active
Viewed 4,122 times
1 Answers
21
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
- 19,129
- 5
- 61
- 68