[英]How can I send tasks to specific queues without execute in Celery?
I've tried sending tasks with send_task
and apply_async
, it's works, but I don't want execute tasks in subprocess, I just want send it to broker.我尝试使用
send_task
和apply_async
发送任务,它有效,但我不想在子进程中执行任务,我只想将它发送给代理。 I used delay
but I can't specify the queue, any tip?我使用了
delay
,但我无法指定队列,有什么提示吗?
I am expecting send a task without executing我期待发送任务而不执行
You can specify which queue tasks will be sent to with the following code:您可以使用以下代码指定将发送到哪些队列任务:
your_celery_app.conf.task_routes = {
your_task_name: {'queue': your_queue_name}
}
your_task_name
is the task name that is printed under [tasks]
when you launch the worker, for example my_app.tasks.my_task.my_task
. your_task_name
是启动工作程序时在[tasks]
下打印的任务名称,例如my_app.tasks.my_task.my_task
。 your_queue_name
is the name of the queue, usually specified with the -Q
command line parameter when launching the worker. your_queue_name
是队列的名称,通常在启动 worker 时使用-Q
命令行参数指定。
For more information, please see https://docs.celeryq.dev/en/latest/userguide/routing.html有关详细信息,请参阅https://docs.celeryq.dev/en/latest/userguide/routing.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.