I have a simple issue, we have as follows:
@task()
def upload_image(request):
var = request.POST
# ... do something
And we call it in another method the delay for this method like this:
job = upload_image.delay(request)
This not works obviously, after I read, you can pass messages to a celery task like a simple arg
, args
or kwargs**
but what I just want is to pass a simple object, not a string or list of strings, is there anyway to do this in celery?
Regards!
As you can read from the docs your example should work.
from celery import task
@task()
def add(x, y):
return x + y
add.delay(2, 2)
只要您使用标准的pickle序列化程序,它就应该起作用。
This does not work with the standard pickler. See more here (basically a duplicate): passing django request object to celery task
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.