From 97a0cb4eabe2b12f8e54e37d92f3f6a7afdae01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=AD=E6=BD=87?= <1576730710@qq.com> Date: Fri, 30 May 2025 09:48:37 +0800 Subject: [PATCH] =?UTF-8?q?[python]=20=E5=9C=A8=E6=B3=A8=E5=86=8C=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E9=87=8D=E8=BF=9E=E6=88=90=E5=8A=9F=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=20=20=E9=87=8D=E6=96=B0=E6=B3=A8=E5=86=8C=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF=E5=88=B0=E6=B3=A8=E5=86=8C=E4=B8=AD?= =?UTF-8?q?=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heart_beat_agent.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/framework/fit/python/plugin/fit_py_heart_beat_agent/heart_beat_agent.py b/framework/fit/python/plugin/fit_py_heart_beat_agent/heart_beat_agent.py index f8d972d9..63c68274 100644 --- a/framework/fit/python/plugin/fit_py_heart_beat_agent/heart_beat_agent.py +++ b/framework/fit/python/plugin/fit_py_heart_beat_agent/heart_beat_agent.py @@ -94,6 +94,7 @@ def _try_heart_beat_once(): f"heart_beat_gap={'{:.3f}'.format(heart_beat_gap)}s, " f"heart_beat_interval={'{:.3f}'.format(_interval() / 1000)}s]") if _FAIL_COUNT != 0: + _registry_fitable_addresses() sys_plugin_logger.info(f"heart beat reconnect success. [fail_count={_FAIL_COUNT}]") _FAIL_COUNT = 0 sys_plugin_logger.debug(f'heart beating success.') @@ -155,3 +156,24 @@ def offline(): @fitable(const.HEART_BEAT_EXIT_UNEXPECTEDLY_GEN_ID, const.HEART_BEAT_EXIT_UNEXPECTEDLY_FIT_ID) def heart_beat_exit_unexpectedly() -> bool: return _HEART_BEAT_EXIT_UNEXPECTEDLY + + +@fit(const.SERVICE_DB_REGISTER_ALL_FIT_SERVICE_GEN_ID) +def register_all_fit_services() -> None: + pass + + +def _registry_fitable_addresses(): + """ + 心跳重连后向注册中心注册。 + """ + try: + register_all_fit_services() + sys_plugin_logger.info("In heart beat agent registry all fitable address success.") + except: + sys_plugin_logger.warning(f"In heart beat agent registry all fitable address failed.") + except_type, except_value, except_traceback = sys.exc_info() + sys_plugin_logger.warning(f"In heart beat agent registry all fitable address error type: {except_type}") + sys_plugin_logger.warning(f"In heart beat agent registry all fitable address error value: {except_value}") + sys_plugin_logger.warning(f"In heart beat agent registry all fitable address error trace back:\n" + f"{''.join(traceback.format_tb(except_traceback))}")