gpt4 book ai didi

python - Celery:如何为基于类的任务创建签名?

转载 作者:行者123 更新时间:2023-12-01 00:50:37 26 4
gpt4 key购买 nike

Python 3.7、 celery 4.3

我注册了一个基于类的任务:

class TaskA(celery_app.Task):
name = 'task_a'

def run(self, my_param):
pass

celery_app.tasks.register(TaskA())

我想创建一个任务链,其中 TaskA 应该是其中一个链接。

我是这样做的:

my_param = "some value"

result = celery.chain(
TaskA.s(my_param),
# ...
)()

我收到错误:

TypeError: s() missing 1 required positional argument: 'self'

最佳答案

替换代码:

my_param = "some value"

result = celery.chain(
TaskA.s(my_param),
# ...
)()

与:

my_param = "some value"

task_ = TaskA() # <------
result = celery.chain(
task_.s(my_param),
# ...
)()

关于python - Celery:如何为基于类的任务创建签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56597321/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com