Merge pull request #83 from moreati/msg-in-a-jar

Fix lingering references to mitogen.core.Receiver.get_data()
pull/87/head
dw 8 years ago committed by GitHub
commit 9d1859796c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -677,7 +677,9 @@ Context Class
recv = context.call_async(os.check_output, 'ls /tmp/') recv = context.call_async(os.check_output, 'ls /tmp/')
try: 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: except mitogen.core.CallError, e:
print 'Call failed:', str(e) print 'Call failed:', str(e)

@ -170,11 +170,12 @@ It is a simple wrapper around the more flexible :meth:`Context.call_async`,
which immediately returns a :class:`Receiver <mitogen.core.Receiver>` wired up which immediately returns a :class:`Receiver <mitogen.core.Receiver>` wired up
to receive the return value instead. A receiver may simply be discarded, kept 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 around indefinitely without ever reading its result, or used to wait on the
results from several calls. Here :meth:`get_data() <mitogen.core.Receiver.get>` results from several calls. Here :meth:`get() <mitogen.core.Receiver.get>`
is called to block the thread until the result arrives:: is called to block the thread until the result arrives::
>>> call = local.call_async(time.time) >>> call = local.call_async(time.time)
>>> print call.get_data() >>> msg = call.get()
>>> print msg.unpickle()
1507292737.75547 1507292737.75547

@ -769,9 +769,10 @@ class Context(object):
def send_await(self, msg, deadline=None): def send_await(self, msg, deadline=None):
"""Send `msg` and wait for a response with an optional timeout.""" """Send `msg` and wait for a response with an optional timeout."""
receiver = self.send_async(msg) receiver = self.send_async(msg)
response = receiver.get_data(deadline) response = receiver.get(deadline)
IOLOG.debug('%r._send_await() -> %r', self, response) data = response.unpickle()
return response IOLOG.debug('%r._send_await() -> %r', self, data)
return data
def __repr__(self): def __repr__(self):
return 'Context(%s, %r)' % (self.context_id, self.name) return 'Context(%s, %r)' % (self.context_id, self.name)

Loading…
Cancel
Save