简体   繁体   English

推迟执行芹菜任务

[英]deferred execution celery task

I want to put a task to celery, but I want the task is executed after 30 seconds instead of executed immediately. 我想将任务放到芹菜上,但是我希望任务在30秒后执行,而不是立即执行。

For example: 例如:

@celery.task
def task():
    # waiting 30 seconds
    do something....

I can use it to make it: sleep(30) , but is there any better solution? 我可以用它来做到: sleep(30) ,但是还有更好的解决方案吗?

The best way would be for that task's task to be to schedule the real task in 30 seconds. 最好的方法是将该任务的任务安排在30秒内安排实际任务。 Something like that: 像这样:

@celery.task
def task():
    RealTask.apply_async(countdown=30)

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

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