diff --git a/docs/api.rst b/docs/api.rst index 615052a3..b6c68354 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -677,7 +677,9 @@ Context Class recv = context.call_async(os.check_output, 'ls /tmp/') try: - print recv.get_data() # Prints output once it is received. + # Prints output once it is received. + msg = recv.get() + print msg.unpickle() except mitogen.core.CallError, e: print 'Call failed:', str(e) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 23008f55..65f89ae9 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -170,11 +170,12 @@ It is a simple wrapper around the more flexible :meth:`Context.call_async`, which immediately returns a :class:`Receiver ` wired up to receive the return value instead. A receiver may simply be discarded, kept around indefinitely without ever reading its result, or used to wait on the -results from several calls. Here :meth:`get_data() ` +results from several calls. Here :meth:`get() ` is called to block the thread until the result arrives:: >>> call = local.call_async(time.time) - >>> print call.get_data() + >>> msg = call.get() + >>> print msg.unpickle() 1507292737.75547 diff --git a/mitogen/core.py b/mitogen/core.py index 2df898ef..b9462d6d 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -769,9 +769,10 @@ class Context(object): def send_await(self, msg, deadline=None): """Send `msg` and wait for a response with an optional timeout.""" receiver = self.send_async(msg) - response = receiver.get_data(deadline) - IOLOG.debug('%r._send_await() -> %r', self, response) - return response + response = receiver.get(deadline) + data = response.unpickle() + IOLOG.debug('%r._send_await() -> %r', self, data) + return data def __repr__(self): return 'Context(%s, %r)' % (self.context_id, self.name)