ck 断开重连

This commit is contained in:
wuaho 2021-04-21 18:23:23 +08:00
parent 3df9a6fb5c
commit f0501b0615
2 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,9 @@ class CK:
self.bulk_max = bulk_max
self.__send_ts = int(time.time())
def set_connect(self, client):
self.client = client
def up_tb_struct(self, db, tb, data):
struct_dict = self.struct_dict.get(f'{db}_{tb}', {})

View File

@ -1,3 +1,6 @@
import clickhouse_driver
from clickhouse_driver import Client
from ck.ck import CK
from common import *
@ -21,6 +24,8 @@ def run():
del msg['type']
ck_client.send(db, table, msg)
except clickhouse_driver.errors.NetworkError:
ck_client.set_connect(Client(**settings.CK_CONFIG))
except Exception as e:
print(traceback.print_exc())