This commit is contained in:
wuaho 2021-08-14 11:19:50 +08:00
parent eef92b3fdc
commit 86aa16574e

View File

@ -11,13 +11,14 @@ __all__ = 'Transmitter',
class Ping(threading.Thread):
def __init__(self, db_client, log):
def __init__(self, db_client, p, log):
threading.Thread.__init__(self)
self.daemon = True
self.ping_ts = 0
self.time_out = 60
self.log = log
self.db_client = db_client
self.p = p
def run(self):
while True:
@ -26,7 +27,7 @@ class Ping(threading.Thread):
# 保持连接
try:
self.ping_ts = ts
self.log.info('保持连接 ping')
self.log.info(f'保持连接{self.p} ping')
self.db_client.execute('select 1')
except:
self.log.error('ping error')
@ -44,7 +45,7 @@ class Transmitter:
self.p = p
def start_ping(self):
t = Ping(self.db_client, self.log)
t = Ping(self.db_client, self.p, self.log)
t.start()
def add_source(self, handler, bulk_max=1000, time_out=60):