Open misli opened 9 years ago
Another possible approach is to use celery signals:
@signals.task_postrun(sender=dbs.tasks.build_image)
def task_postrun_handler(sender, **kwargs):
...
If I'm reading it right, task_postrun_handler() would be run in the server not the worker. http://celery.readthedocs.org/en/latest/userguide/signals.html
I've implemented state change in DB via signals: https://github.com/DBuildService/dbs-server/commit/ef6bc60152ac9d7b8687a1d2db752b12462c14ba#diff-993fb812f6bae891a1e5603a70d7a96bR31
IMO, this could really be the easiest and most flexible solution. Good job scouting that out, Tim.
If we really need to use callback at all (i believe we do not), use string definition of callback ('module.submodule.func') and pass it to task. In the task use django.utils.module_loading.import_string to get the actual callback function.