diff --git a/ck/ck.py b/ck/ck.py index 72de08c..408afde 100644 --- a/ck/ck.py +++ b/ck/ck.py @@ -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}', {}) diff --git a/main.py b/main.py index 018e06e..d2f33df 100644 --- a/main.py +++ b/main.py @@ -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())