Flask Tiq回调必须是参与者
当使用Flask Tiq回调必须是参与者,flask,dramatiq,Flask,Dramatiq,当使用戏剧化1.9.0(戏剧化0.6.0)时,我无法在成功时调用,或在失败时调用。状态回调可以这样使用: @dramatiq.actor def taskFailed(message_data, exception_data): print("Task failed") @dramatiq.actor def taskSucceeded(message_data, result): print("Success") dramatiqTa
戏剧化1.9.0
(戏剧化0.6.0
)时,我无法在成功时调用,或在失败时调用。状态回调可以这样使用:
@dramatiq.actor
def taskFailed(message_data, exception_data):
print("Task failed")
@dramatiq.actor
def taskSucceeded(message_data, result):
print("Success")
dramatiqTask.send_with_options(args=(1, 2, 3), on_success=taskSucceeded, on_failure=taskFailed)
但是,我得到了以下错误:
ERROR - on_failure value must be an Actor
在../site packages/戏剧性地/tramatiq/actor.py
中有
def message_with_options(self, *, args=None, kwargs=None, **options):
for name in ["on_failure", "on_success"]:
callback = options.get(name)
print(str(type(callback))) # Returns "<class 'flask_dramatiq.LazyActor'>"
if isinstance(callback, Actor):
options[name] = callback.actor_name
elif not isinstance(callback, (type(None), str)):
raise TypeError(name + " value must be an Actor")
def message_,带有选项(self,*,args=None,kwargs=None,**选项):
对于[“失败时”、“成功时”]中的名称:
callback=options.get(名称)
打印(str(类型(回调))#返回“”
如果isinstance(回调、参与者):
选项[名称]=callback.actor\u名称
elif not isinstance(回调,(类型(无),str)):
raise TypeError(名称+“值必须是参与者”)
这表明回调不是来自类型Actor
,而是来自类型LazyActor
如果我使用import-tramatiq as\u-tramatiq
导入原始包,并将decorator更改为\u-tramatiq.actor
,则什么也不会发生。任务无法启动
如何在tiq
中定义回调