将参数请求传递给Django中的celery任务 [英] Pass parameter request to a celery task in Django
问题描述
我有一个简单的问题,我们有以下问题:
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)
这显然不起作用,在我阅读之后,您可以将消息传递给芹菜任务,例如简单的 arg
, args
或 kwargs **
,但我只想传递一个简单的对象,而不是字符串或字符串列表,是否在芹菜中可以做到这一点?
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?
问候!
推荐答案
这不适用于标准酸洗机。在此处查看更多信息(基本上是重复的内容):将Django请求对象传递给芹菜任务
This does not work with the standard pickler. See more here (basically a duplicate): passing django request object to celery task
这篇关于将参数请求传递给Django中的celery任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!