简体   繁体   English

你在哪里设置芹菜任务的task_id?

[英]Where do you set the task_id of a celery task?

I am having trouble finding any example of setting a task_id with my own task_id 我无法找到使用自己的task_id设置task_id的任何示例

something along these lines... 沿着这些方向......

def testview1(request):
    for i in xrange(0,1000):
        result = add.delay( i, 4,task_id = i)
        print result.info
        #value = result.wait()
    return HttpResponse("Done") 


@task()
def add(task_id, x, y):
    print add.task_id
    print str(x+y)
    return x + y

delay doesn't support options, it's a shortcut to apply_async: 延迟不支持选项,它是apply_async的快捷方式:

add.apply_async(args, kwargs, task_id=i)

add.apply_async((1, 4), task_id=i)

Also the id of the current task is in task.request.id not task.id like you have above. 此外,当前任务的id在task.request.id而不是像上面那样的task.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM