core: split _broker_shutdown() out into its own function.

Makes _broker_main() logic much clearer.
issue260
David Wilson 6 years ago
parent 8ef8f7b123
commit 711aed7a4c

@ -2330,12 +2330,7 @@ class Broker(object):
for (side, func) in self.poller.poll(timeout):
self._call(side.stream, func)
def _broker_main(self):
try:
while self._alive:
self._loop_once()
fire(self, 'shutdown')
def _broker_shutdown(self):
for _, (side, _) in self.poller.readers + self.poller.writers:
self._call(side.stream, side.stream.on_shutdown)
@ -2352,6 +2347,14 @@ class Broker(object):
for _, (side, _) in self.poller.readers + self.poller.writers:
LOG.error('_broker_main() force disconnecting %r', side)
side.stream.on_disconnect(self)
def _broker_main(self):
try:
while self._alive:
self._loop_once()
fire(self, 'shutdown')
self._broker_shutdown()
except Exception:
LOG.exception('_broker_main() crashed')

Loading…
Cancel
Save