[openstack-dev] Asynchrounous programming: replace eventlet with asyncio
Victor Stinner
victor.stinner at enovance.com
Fri Feb 7 23:00:00 UTC 2014
Le jeudi 6 février 2014, 22:32:26 Zane Bitter a écrit :
> [BTW am I right in thinking that in trollius you _have_ to drive your
> co-routines from a top-level Task? That's not the case in Heat (although
> we do anyway), or IIUC in asyncio - I was expecting e.g. the exception
> handling for Return to happen in the coroutine decorator rather than in
> Task. Just curious.]
Sorry, but I don't understand what you mean by "to drive your co-routines from
a top-level Task". Here is a simple example chaining two coroutines:
http://docs.python.org/dev/library/asyncio-task.html#example-chain-coroutines
> The main reason asyncio exists (as opposed to, say, twisted) is that
> it's supposed to be the standard place to get an event loop from, so
> that everybody ends up using the same event loop. Right now, though,
> there are still lots of competing event loops (including eventlet) and
> it's difficult to see how introducing another one helps in the short
> term.
asyncio can use eventlet (greenlet in fact) event loop though greenio.
asyncio is more than an event loop, it's a nice API to use it. For example, I
prefer coroutines (yield from) to callbacks!
Victor
More information about the OpenStack-dev
mailing list