芹菜:意外 run_command() 需要 1 个位置参数,但给出了 318 个错误
Celery: Getting unexpected run_command() takes 1 positional argument but 318 were given error
我正在尝试 运行 一个异步任务,但遇到意外错误:run_command() 接受 1 个位置参数,但给出了 318 个。
我有一个命令列表,我想从 celery 任务中 运行。
run_command.chunks(iter(commands), 10).group().apply_async()
@task
def run_command(commands):
for command in commands:
print("RUNNING, ", command)
print("Pid: ", os.getpid())
os.system(command)
如上所示,我正在尝试将我的命令分解为将并行执行的批次。
感谢帮助
Celery 将其位置参数视为 *args
,因此您的 commands 可迭代中的每个 command 应该看起来像 ('commandtext',)
commands = ['hello', 'world', '!']
@task
def run_command(command):
'''run command'''
run_command.chunks(zip(commands), 2).group().apply_async()
我正在尝试 运行 一个异步任务,但遇到意外错误:run_command() 接受 1 个位置参数,但给出了 318 个。 我有一个命令列表,我想从 celery 任务中 运行。
run_command.chunks(iter(commands), 10).group().apply_async()
@task
def run_command(commands):
for command in commands:
print("RUNNING, ", command)
print("Pid: ", os.getpid())
os.system(command)
如上所示,我正在尝试将我的命令分解为将并行执行的批次。
感谢帮助
Celery 将其位置参数视为 *args
,因此您的 commands 可迭代中的每个 command 应该看起来像 ('commandtext',)
commands = ['hello', 'world', '!']
@task
def run_command(command):
'''run command'''
run_command.chunks(zip(commands), 2).group().apply_async()