From f0501b061526d52c03de4a2f4077fce849bfe805 Mon Sep 17 00:00:00 2001 From: wuaho Date: Wed, 21 Apr 2021 18:23:23 +0800 Subject: [PATCH] =?UTF-8?q?ck=20=E6=96=AD=E5=BC=80=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ck/ck.py | 3 +++ main.py | 5 +++++ 2 files changed, 8 insertions(+) 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())