service: unregister receiver at shutdown; closes #445.

issue510
David Wilson 5 years ago
parent 9916adc0a3
commit dc92e529bc

@ -298,6 +298,12 @@ Core Library
* `#444 <https://github.com/dw/mitogen/issues/444>`_: messages regarding
unforwardable extension module are no longer logged as errors.
* `#445 <https://github.com/dw/mitogen/issues/445>`_: service pools unregister
the :data:`mitogen.core.CALL_SERVICE` handle at shutdown, ensuring any
outstanding messages are either processed by the pool as it shuts down, or
have dead messages sent in reply to them, preventing peer contexts from
hanging due to a forgotten buffered message.
* `#453 <https://github.com/dw/mitogen/issues/453>`_: the loggers used in
children for standard IO redirection have propagation disabled, preventing
accidental reconfiguration of the :mod:`logging` package in a child from

@ -479,6 +479,7 @@ class Pool(object):
def stop(self, join=True):
self.closed = True
self._receiver.close()
self._select.close()
if join:
self.join()

@ -89,5 +89,18 @@ class PermissionTest(testlib.RouterMixin, testlib.TestCase):
self.assertTrue(msg in exc.args[0])
class CloseTest(testlib.RouterMixin, testlib.TestCase):
klass = mitogen.service.Pool
def test_receiver_closed(self):
pool = self.klass(router=self.router, services=[])
pool.stop()
self.assertEquals(None, pool._receiver.handle)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: self.router.myself().call_service(MyService, 'foobar'))
self.assertEquals(e.args[0], self.router.invalid_handle_msg)
if __name__ == '__main__':
unittest2.main()

Loading…
Cancel
Save