core/parent: add Context.call_no_reply().

pull/262/head
David Wilson 7 years ago
parent b3a5fa70b0
commit 9e78c20eba

@ -857,7 +857,7 @@ Context Class
.. method:: call (fn, \*args, \*\*kwargs) .. method:: call (fn, \*args, \*\*kwargs)
Equivalent to :py:meth:`call_async(fn, \*args, \**kwargs).get_data() Equivalent to :py:meth:`call_async(fn, \*args, \**kwargs).get().unpickle()
<call_async>`. <call_async>`.
:returns: :returns:
@ -866,6 +866,14 @@ Context Class
:raises mitogen.core.CallError: :raises mitogen.core.CallError:
An exception was raised in the remote context during execution. An exception was raised in the remote context during execution.
.. method:: call_no_reply (fn, \*args, \*\*kwargs)
Send a function call, but expect no return value. If the call fails,
the full exception will be logged to the target context's logging framework.
:raises mitogen.core.CallError:
An exception was raised in the remote context during execution.
Receiver Class Receiver Class

@ -1857,12 +1857,16 @@ class ExternalContext(object):
for msg in self.recv: for msg in self.recv:
try: try:
ret = self._dispatch_one(msg) ret = self._dispatch_one(msg)
_v and LOG.debug('_dispatch_calls: %r -> %r', msg, ret)
if msg.reply_to: if msg.reply_to:
msg.reply(ret) msg.reply(ret)
except Exception: except Exception:
e = sys.exc_info()[1] e = sys.exc_info()[1]
_v and LOG.debug('_dispatch_calls: %s', e) if msg.reply_to:
msg.reply(CallError(e)) _v and LOG.debug('_dispatch_calls: %s', e)
msg.reply(CallError(e))
else:
LOG.exception('_dispatch_calls: %r', msg)
self.dispatch_stopped = True self.dispatch_stopped = True
def main(self): def main(self):

@ -912,6 +912,11 @@ class Context(mitogen.core.Context):
receiver = self.call_async(fn, *args, **kwargs) receiver = self.call_async(fn, *args, **kwargs)
return receiver.get().unpickle(throw_dead=False) return receiver.get().unpickle(throw_dead=False)
def call_no_reply(self, fn, *args, **kwargs):
LOG.debug('%r.call_no_reply(%r, *%r, **%r)',
self, fn, args, kwargs)
self.send(make_call_msg(fn, *args, **kwargs))
def shutdown(self, wait=False): def shutdown(self, wait=False):
LOG.debug('%r.shutdown() sending SHUTDOWN', self) LOG.debug('%r.shutdown() sending SHUTDOWN', self)
latch = mitogen.core.Latch() latch = mitogen.core.Latch()

Loading…
Cancel
Save