简体   繁体   English

Celery任务集中子任务的自定义路由

[英]Custom routing for subtask in Celery taskset

Is it possible to set subtask parameters "queue" and "routing_key" not in apply_async(). 是否可以在apply_async()中设置子任务参数“queue”和“routing_key”。

It is necessary in Taskset that each subtask went to custom queue and routing_key. 在Taskset中,每个子任务都必须转到自定义队列和routing_key。

Looks like: 看起来像:

tasks = []
for item in items:   
    tasks.append(task_name.s((params).<method for set custom queue and routing_key>))
job = TaskSet(tasks=tasks)

It is not too clear what is the question. 问题是什么并不太清楚。 If you are asking if you can give routing_key and queue arguments to subtasks you can if you use subtask() instead of s() . 如果您询问是否可以将routing_keyqueue参数赋予子任务,则可以使用routing_key subtask()而不是s()

From subtask doc: 子任务文档:

options – Additional options to Task.apply_async(). options - Task.apply_async()的附加选项。

Yes, you can use any of the apply_sync arguments in the subtask call. 是的,您可以在子任务调用中使用任何apply_sync参数。

See the "Calling API" in the docs 请参阅文档中的“调用API”

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

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