MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / HeartBeat

Class HeartBeat

client/node/servertask/nodemgr.py:100–131  ·  view source on GitHub ↗

心跳上报

Source from the content-addressed store, hash-verified

98
99
100class HeartBeat(object):
101 """
102 心跳上报
103 """
104 def __init__(self, node_server):
105 """
106
107 :param node_server: 上报api实例
108 :return:
109 """
110 self._server = node_server
111 self._beat_interval = 8 # sec 心跳上传的频率
112
113 def _thread_beat(self):
114 """
115 心跳上报线程
116 """
117 while True:
118 host_ip = HostNetMgr().get_host_ip()
119 data = {"puppy_ip": host_ip}
120 # LogPrinter.info(f">>> data: {data}")
121 try:
122 self._server.heart_beat(data)
123 except Exception as err:
124 LogPrinter.exception(f"heart beat error: {str(err)}")
125 time.sleep(self._beat_interval)
126
127 def start(self):
128 beat_thread = threading.Thread(target=self._thread_beat)
129 beat_thread.daemon = True
130 beat_thread.start()
131 LogPrinter.info("heart beat thread is started.")
132
133
134class NodeStatusMonitor(object):

Callers 1

runMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected