Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 关闭芹菜工人_Python_Celery - Fatal编程技术网

Python 关闭芹菜工人

Python 关闭芹菜工人,python,celery,Python,Celery,例如: @app.task() def f(num): if num == 0: # shutdown this worker # celery will not distribute any tasks to this worker else: return num 芹菜-任务工作者--日志级别=信息-n工作者1 当芹菜将0分配给worker1时,worker1将被杀死。 在文件中 但这是错误的,我把它改成 >>&g

例如:

@app.task()
def f(num):
    if num == 0:
        # shutdown this worker
        # celery will not distribute any tasks to this worker
    else:
        return num
芹菜-任务工作者--日志级别=信息-n工作者1

当芹菜将0分配给worker1时,worker1将被杀死。 在文件中

但这是错误的,我把它改成

>>> broadcast("shutdown", destination=["worker1"])
它也不起作用


那么,如何实现这个功能呢?

通常工人的名字以“芹菜”开头。因此,在您的情况下,请尝试以下代码:
芹菜.control.broadcast('shutdown',destination=['celery@worker1“]

在您的广播和芹菜文档中,它似乎缺少一个quote@user2097159是的,但当我添加报价时,它也不起作用。
>>> broadcast("shutdown", destination=["worker1"])