Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 479
Nick Avatar asked Jul 11 '12 08:07

Nick


1 Answers

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.

like image 175
Simeon Visser Avatar answered Sep 20 '22 05:09

Simeon Visser