Django-Celery: Passing Request Object to Employee

How can I pass a django request object to a celery worker. When trying to pass a request object, it causes an error

Can't Pickle Input Objects 

Celery seems to serialize any arguments passed to the worker. I tried using other serialization methods like JSON.

 CELERY_TASK_SERIALIZER = "JSON" 

But it does not work.

Is it possible to configure celery so that it does not serialize the data. Or I can convert the request object to a string before moving on to the worker, and then convert the object back to worker again.

Thanks in advance...

+6
source share
1 answer

You cannot clear Django request objects (see this question for more details). Instead, you should pass the appropriate information from the request object that you need for Celery tasks.

You should not have problems transferring other information to the Celery task, since most objects can be pickled without problems.

+9
source

Source: https://habr.com/ru/post/920194/


All Articles