diff --git a/v2/transmitter.py b/v2/transmitter.py index 7606d48..c04a4e9 100644 --- a/v2/transmitter.py +++ b/v2/transmitter.py @@ -26,17 +26,19 @@ class Transmitter: def check_send(self): ts = int(time.time()) + if self.ping_ts + 60 < ts: + # 保持连接 + self.ping_ts = ts + print('保持连接') + self.db_client.execute('select 1') + for h, p in self.slots.items(): tb, buffer = h.buffer_pool buffer_size = len(buffer) if (p['ts'] + p['time_out'] <= ts or buffer_size >= p['bulk_max']) and buffer_size > 0: p['ts'] = ts yield tb, buffer - if self.ping_ts + 60 < ts: - # 保持连接 - self.ping_ts = ts - print('保持连接') - self.db_client.execute('select 1') + @staticmethod def flat_data(data: dict):