Commit 0c817459 authored by Jalin's avatar Jalin

增加节点订阅消息丢失重连

parent 05ffcffe
...@@ -202,7 +202,12 @@ class Cluster(): ...@@ -202,7 +202,12 @@ class Cluster():
def subscribe(self): def subscribe(self):
while True: while True:
try:
message = self.pubsub.get_message() message = self.pubsub.get_message()
except RuntimeError as err:
if 'args' in dir(err) and err.args[0].find('pubsub connection not set') >= 0: # 失去重连
self.pubsub.subscribe(self.KEY_CHANNEL_LOG, self.KEY_CHANNEL_EVENT)
continue
if message: if message:
if message.get('type') == 'message' and message.get('channel') == self.KEY_CHANNEL_LOG and message.get( if message.get('type') == 'message' and message.get('channel') == self.KEY_CHANNEL_LOG and message.get(
'data'): 'data'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment