diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-21 04:17:25 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-21 04:17:25 +0100 |
commit | ea24997de038d20c1b98496cc8abbdc595d460ca (patch) | |
tree | 484732a9dbc075dd8c16c28f2f391b859df33b06 /README | |
parent | b02bfe02f265c9a17f3ae77d86c8f02f42adf758 (diff) | |
download | aioeventlet-ea24997de038d20c1b98496cc8abbdc595d460ca.tar.gz |
Add the wrap_greenthread() function
Diffstat (limited to 'README')
-rw-r--r-- | README | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -72,6 +72,38 @@ Hello World:: loop.close() +Use a greenthread in a coroutine +-------------------------------- + +Use the ``wrap_greenthread()`` function to wrap a greenthread into a Future +object. The Future object waits for the completion of a greenthread. + +Example with asyncio:: + + def slow_sum(x, y): + eventlet.sleep(1.0) + return x + y + + @asyncio.coroutine + def coro_sum(): + gt = eventlet.spawn(slow_sum, 1, 2) + fut = aiogreen.wrap_greenthread(gt, loop=loop) + result = yield from fut + return result + +Note: In debug mode, when a greenthread raises an exception, the exception is +logged to sys.stderr by eventlet, even if it is correctly copied to the Future +object. + + +API +=== + +Functions which are not in asyncio: + +* ``wrap_greenthread(gt)``: wrap a greenthread into a Future object + + Installation ============ @@ -139,6 +171,7 @@ only call the callback once per loop iteration. Changes: +* Add the ``wrap_greenthread()`` function to wrap a greenthread into a Future * Support also eventlet 0.14, not only eventlet 0.15 or newer * Support eventlet with monkey-patching * Rewrite the code handling file descriptors to ensure that the listener is |