Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service callback 的文档例子有错, 且回调不生效 #197

Open
Randix6644 opened this issue Nov 13, 2023 · 0 comments
Open

service callback 的文档例子有错, 且回调不生效 #197

Randix6644 opened this issue Nov 13, 2023 · 0 comments

Comments

@Randix6644
Copy link

Randix6644 commented Nov 13, 2023

没有self.callback 这个属性, 应该是typo? 应该是callback?
image

多次回调也是没有, self.callback 这个属性,而且, else if 是个语法错误。
image

另外就是回调不成功

class WaitCallbackService(Service):
    __need_schedule__ = True
    __multi_callback_enabled__ = True

    def _external_api_call(self):
        pass

    def execute(self, data, parent_data):
        self._external_api_call()
        return True

    def schedule(self, data, parent_data, callback_data=None):

        status = callback_data.get('status') or 0

        if status < 0:
            data.outputs.ex_data = 'task failed with code: %s' % status
            return False
        elif status < 1:
            print("no next???")
            return True

        self.finish_schedule()


class WaitCallbackComponent(Component):
    name = 'WaitCallbackComponent'
    code = 'wait_callback_comp'
    bound_service = WaitCallbackService

无论返回true 或者false , 运行一次命令 , schedule 就结束了。

python manage.py run_component wait_callback_comp --settings=foo

日志:

2023-11-14 11:17:21,483 - INFO - Start to run component [wait_callback_comp] with data: <inputs: {} | outputs: {}>, parent_data: <inputs: {} | outputs: {}>
2023-11-14 11:17:21,483 - INFO - Start to callback component with callbackdata: {}
no next???
2023-11-14 11:17:21,483 - INFO - Schedule return [True], finish running

另外我在Django shell 运行会报错

python manage.py shell --settings=foo
from pipeline.eri.runtime import BambooDjangoRuntime
from bamboo_engine import api
from bamboo_engine import builder
from bamboo_engine.builder import EmptyStartEvent, ServiceActivity, EmptyEndEvent


# 使用 builder 构造出流程描述结构
start = EmptyStartEvent()
act = ServiceActivity(component_code='wait_callback_comp')
end = EmptyEndEvent()

start.extend(act).extend(end)

pipeline = builder.build_tree(start)
api.run_pipeline(runtime=BambooDjangoRuntime(), pipeline=pipeline)

报错信息:

{'ex_data': 'Traceback (most recent call last):\n  File "/home/apps/.local/lib/python3.8/site-packages/bamboo_engine/engine.py", line 678, in execute\n    execute_result = handler.execute(process_info, loop, inner_loop, version)\n  File "/home/apps/.local/lib/python3.8/site-packages/bamboo_engine/handlers/service_activity.py", line 172, in execute\n    service = self.runtime.get_service(code=self.node.code, version=self.node.version)\n  File "/home/apps/.local/lib/python3.8/site-packages/pipeline/eri/imp/plugin_manager.py", line 37, in get_service\n    comp_cls = ComponentLibrary.get_component_class(code, version)\n  File "/home/apps/.local/lib/python3.8/site-packages/pipeline/component_framework/library.py", line 47, in get_component_class\n    raise ComponentNotExistException("component %s does not exist." % component_code)\npipeline.exceptions.ComponentNotExistException: component wait_callback_comp does not exist.\n'}

但数据库看到是有这个component的, 且上述使用run_component命令也是正常的

update

run_component 应该是在本地跑的, 在Django shell 跑的是在真正的worker 上跑, 我的worker 和 producer 不在同一个机器上, 因此需要重启worker 才会生效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant