issue #547: fix service_test failures.

pull/612/head
David Wilson 5 years ago
parent 41d180495a
commit cc02906d2a

@ -3524,7 +3524,8 @@ class Dispatcher(object):
def _dispatch_calls(self): def _dispatch_calls(self):
for msg in self.recv: for msg in self.recv:
if msg.handle == STUB_CALL_SERVICE: if msg.handle == STUB_CALL_SERVICE:
self._init_service_pool() if msg.src_id == mitogen.context_id:
self._init_service_pool()
continue continue
chain_id, ret = self._dispatch_one(msg) chain_id, ret = self._dispatch_one(msg)

@ -496,15 +496,12 @@ class Pool(object):
self.router = router self.router = router
self._activator = self.activator_class() self._activator = self.activator_class()
self._ipc_latch = mitogen.core.Latch() self._ipc_latch = mitogen.core.Latch()
self._receiver = recv or mitogen.core.Receiver( self._receiver = mitogen.core.Receiver(
router=router, router=router,
handle=mitogen.core.CALL_SERVICE, handle=mitogen.core.CALL_SERVICE,
overwrite=overwrite, overwrite=overwrite,
) )
# If self._receiver was inherited from mitogen.core.Dispatcher, we must
# remove its stub notification function before adding it to our Select.
self._receiver.notify = None
self._select = mitogen.select.Select(oneshot=False) self._select = mitogen.select.Select(oneshot=False)
self._select.add(self._receiver) self._select.add(self._receiver)
self._select.add(self._ipc_latch) self._select.add(self._ipc_latch)
@ -516,6 +513,16 @@ class Pool(object):
} }
self._invoker_by_name = {} self._invoker_by_name = {}
if recv is not None:
# When inheriting from mitogen.core.Dispatcher, we must remove its
# stub notification function before adding it to our Select. We
# always overwrite this receiver since the standard service.Pool
# handler policy differs from the one inherited from
# core.Dispatcher.
recv.notify = None
self._select.add(recv)
self._func_by_source[recv] = self._on_service_call
for service in services: for service in services:
self.add(service) self.add(service)
self._py_24_25_compat() self._py_24_25_compat()

Loading…
Cancel
Save