Django-celery : Passing request Object to worker

若如初见. 提交于 2019-12-23 09:37:51

问题


How can i pass django request object to celery worker. When try to pass the request object it throws a Error

Can't Pickle Input Objects

It seems that celery serialize any arguments passed to worker. I tried using other serialization methods like JSON.

CELERY_TASK_SERIALIZER = "JSON"

But it is not working.

Is it possible to configure celery so that it won't serialize data. Or can i convert request object to a string before passing to worker and then convert again back to object in worker.

Thanks in advance...


回答1:


You can't pickle Django's request objects (see this question for more details). Instead you should pass the relevant information from the request object that you need to the Celery tasks.

You should have no problem passing other information to a Celery task as most objects can be pickled without a problem.



来源:https://stackoverflow.com/questions/11428602/django-celery-passing-request-object-to-worker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!