简体   繁体   中英

Django-celery : Passing request Object to worker

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM