我有这个任务:
@app.task(rate_limit='1/m')
def very_long_process():
pass # not very long, lol
我从Python函数开始:
very_long_process.delay()
如果此任务的另一个实例已在运行,我不想启动另一个甚至排队。
如何检查是否已有1个正在运行(并获取其ID)?
答案 0 :(得分:1)
async_result = very_long_process.delay()
task_id = async_result.id
task_status = async_result.status
task_finished = async_result.ready() # to check if task finished its execution
task_succeeded = async_result.successful() # to check if task finished its execution with success