简体   繁体   中英

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. I used delay but I can't specify the queue, any tip?

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_queue_name is the name of the queue, usually specified with the -Q command line parameter when launching the worker.

For more information, please see https://docs.celeryq.dev/en/latest/userguide/routing.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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