issue #481: avoid crash if disconnect occurs during forward_modules()

pull/564/head
David Wilson 5 years ago
parent 92b1648729
commit b263e01867

@ -922,6 +922,11 @@ class ModuleResponder(object):
fullname, _, _ = str_rpartition(fullname, u'.')
stream = self._router.stream_by_id(context.context_id)
if stream is None:
LOG.debug('%r: dropping forward of %s to no longer existent '
'%r', self, path[0], context)
return
for fullname in reversed(path):
self._send_module_and_related(stream, fullname)
self._send_forward_module(stream, context, fullname)

@ -167,6 +167,19 @@ class BrokenModulesTest(testlib.TestCase):
class ForwardTest(testlib.RouterMixin, testlib.TestCase):
def test_forward_to_nonexistent_context(self):
nonexistent = mitogen.core.Context(self.router, 123)
capture = testlib.LogCapturer()
capture.start()
self.broker.defer_sync(lambda:
self.router.responder.forward_modules(
nonexistent,
['mitogen.core']
)
)
s = capture.stop()
self.assertTrue('dropping forward of' in s)
def test_stats(self):
# Forwarding stats broken because forwarding is broken. See #469.
c1 = self.router.local()

Loading…
Cancel
Save