Reputation: 127
Not able to pass Django request parameter to celery task
i am calling the celery task method like this. My_task((request, application_data.id), task_id=task_id)
And my task method is like this: @shared_task(name="create-cloud-storage-task") def My_task(request_data, id):
But it throwing error saying cannot send the request object? What is wrong in this code
Upvotes: 0
Views: 1500
Reputation: 4635
Since the request object contains references to things which aren't practical to serialize — like uploaded files, or the socket associated with the request — there's no general purpose way to serialize it.
Instead, you should just pull out and pass the portions of it that you need. For example, something like:
If you're using user_id in your task, or whatever else you'll be using.
My_task((request.user.id, application_data.id), task_id=task_id)
@shared_task(name="create-cloud-storage-task")
def My_task(request_user_id, id):
Reference : passing django request object to celery task
Upvotes: 0