django - Calling a celery task from another celery task -
i have celery task called send_async_fax , called send_notifications. send_async_fax can called directly. if call send_notifications, however, send_async_fax called.
send_async_fax has number of arguments 1 of list of file objects. if call send_async_fax directly, seems go planned. however, when it's called indirectly, via send_notifications, find list of valid open files degrades list of uninitialized files.
my hunch send_notifications was, in fact, creating separate asynchronous tasks sending faxes when send_async_fax.delay called (which, of course, makes sense). doing this, however, suspect file references getting messed up, or send_notifications closing files before send_async_fax gets operate on them.
to test hunch, tried calling send_async_fax in send_notifications without using delay function (i.e., send_async_fax(*args) instead of send_async_fax.delay(*args)). didn't change anything. then, commented out task decorator send_async_fax make regular function. in case, works expected.
so, working, obvious solution make synchronous version of faxing function , use it, instead of async version, when calling celery task. i'm hoping, however, there's more elegant solution this. help.
- celery==3.0.19
- django-celery==3.0.17
i bet has trying serialize open files arguments delayed task.
try sending fullpath filenames input parameters send_async_fax function , opening files in send_async_fax.
i put example here of 1 task calling another:
https://github.com/brentpayne/django-celery-example/blob/master/polls/tasks.py
but might want more like:
group( send_async_fax.map(my_list_to_fax) ).delay()
Comments
Post a Comment