|
|
@ -1201,6 +1201,7 @@ class Router(object):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, broker):
|
|
|
|
def __init__(self, broker):
|
|
|
|
self.broker = broker
|
|
|
|
self.broker = broker
|
|
|
|
|
|
|
|
listen(broker, 'crash', self._cleanup_handlers)
|
|
|
|
listen(broker, 'shutdown', self.on_broker_shutdown)
|
|
|
|
listen(broker, 'shutdown', self.on_broker_shutdown)
|
|
|
|
|
|
|
|
|
|
|
|
# Here seems as good a place as any.
|
|
|
|
# Here seems as good a place as any.
|
|
|
@ -1230,7 +1231,11 @@ class Router(object):
|
|
|
|
for context in self._context_by_id.itervalues():
|
|
|
|
for context in self._context_by_id.itervalues():
|
|
|
|
context.on_shutdown(self.broker)
|
|
|
|
context.on_shutdown(self.broker)
|
|
|
|
|
|
|
|
|
|
|
|
for _, func in self._handle_map.itervalues():
|
|
|
|
self._cleanup_handlers()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _cleanup_handlers(self):
|
|
|
|
|
|
|
|
while self._handle_map:
|
|
|
|
|
|
|
|
_, (_, func) = self._handle_map.popitem()
|
|
|
|
func(_DEAD)
|
|
|
|
func(_DEAD)
|
|
|
|
|
|
|
|
|
|
|
|
def register(self, context, stream):
|
|
|
|
def register(self, context, stream):
|
|
|
@ -1415,6 +1420,7 @@ class Broker(object):
|
|
|
|
side.stream.on_disconnect(self)
|
|
|
|
side.stream.on_disconnect(self)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
LOG.exception('_broker_main() crashed')
|
|
|
|
LOG.exception('_broker_main() crashed')
|
|
|
|
|
|
|
|
fire(self, 'crash')
|
|
|
|
|
|
|
|
|
|
|
|
fire(self, 'exit')
|
|
|
|
fire(self, 'exit')
|
|
|
|
|
|
|
|
|
|
|
|