issue #406: attempt Broker cleanup in case of a crash.
This commit is contained in:
parent
175fc377d2
commit
10af266678
|
@ -2473,6 +2473,13 @@ class Broker(object):
|
||||||
for (side, func) in self.poller.poll(timeout):
|
for (side, func) in self.poller.poll(timeout):
|
||||||
self._call(side.stream, func)
|
self._call(side.stream, func)
|
||||||
|
|
||||||
|
def _broker_exit(self):
|
||||||
|
for _, (side, _) in self.poller.readers + self.poller.writers:
|
||||||
|
LOG.error('_broker_main() force disconnecting %r', side)
|
||||||
|
side.stream.on_disconnect(self)
|
||||||
|
|
||||||
|
self.poller.close()
|
||||||
|
|
||||||
def _broker_shutdown(self):
|
def _broker_shutdown(self):
|
||||||
for _, (side, _) in self.poller.readers + self.poller.writers:
|
for _, (side, _) in self.poller.readers + self.poller.writers:
|
||||||
self._call(side.stream, side.stream.on_shutdown)
|
self._call(side.stream, side.stream.on_shutdown)
|
||||||
|
@ -2487,12 +2494,6 @@ class Broker(object):
|
||||||
'more child processes still connected to '
|
'more child processes still connected to '
|
||||||
'our stdout/stderr pipes.', self)
|
'our stdout/stderr pipes.', self)
|
||||||
|
|
||||||
for _, (side, _) in self.poller.readers + self.poller.writers:
|
|
||||||
LOG.error('_broker_main() force disconnecting %r', side)
|
|
||||||
side.stream.on_disconnect(self)
|
|
||||||
|
|
||||||
self.poller.close()
|
|
||||||
|
|
||||||
def _broker_main(self):
|
def _broker_main(self):
|
||||||
"""
|
"""
|
||||||
Handle events until :meth:`shutdown`. On shutdown, invoke
|
Handle events until :meth:`shutdown`. On shutdown, invoke
|
||||||
|
@ -2509,6 +2510,7 @@ class Broker(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('_broker_main() crashed')
|
LOG.exception('_broker_main() crashed')
|
||||||
|
|
||||||
|
self._broker_exit()
|
||||||
fire(self, 'exit')
|
fire(self, 'exit')
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
|
Loading…
Reference in New Issue