Fixed syndic event bus connection.

Connect syndic to master event bus in a coroutine. This fixes connection
timeout handling and prevents CPU utilization by connect loop if no
master is running.
This commit is contained in:
Dmitry Kuzmenko 2016-08-26 11:34:59 +03:00
parent ea8e1385c1
commit ab1afd002e

View file

@ -687,6 +687,7 @@ class IPCMessageSubscriber(IPCClient):
except Exception as exc:
log.error('Exception occurred while Subscriber handling stream: {0}'.format(exc))
@tornado.gen.coroutine
def read_async(self, callback):
'''
Asynchronously read messages and invoke a callback when they are ready.
@ -695,13 +696,14 @@ class IPCMessageSubscriber(IPCClient):
'''
while not self.connected():
try:
self.connect()
yield self.connect(timeout=5)
except tornado.iostream.StreamClosedError:
log.trace('Subscriber closed stream on IPC {0} before connect'.format(self.socket_path))
yield tornado.gen.sleep(1)
except Exception as exc:
log.error('Exception occurred while Subscriber connecting: {0}'.format(exc))
self.io_loop.spawn_callback(self._read_async, callback)
yield tornado.gen.sleep(1)
yield self._read_async(callback)
def close(self):
'''