简体   繁体   English

如何在不执行 Celery 的情况下将任务发送到特定队列?

[英]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_taskapply_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.

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