[openstack-dev] [oslo] Asyncio and oslo.messaging
Victor Stinner
victor.stinner at enovance.com
Mon Jul 7 14:12:42 UTC 2014
Le lundi 7 juillet 2014, 11:26:27 Gordon Sim a écrit :
> > When we switch to asyncio's event loop, all of this code needs to be
> > ported to asyncio's explicitly asynchronous approach. We might do:
> > @asyncio.coroutine
> >
> > def foo(self):
> > result = yield from some_async_op(...)
> > return do_stuff(result)
> >
> > or:
> > @asyncio.coroutine
> > def foo(self):
> > fut = Future()
> > some_async_op(callback=fut.set_result)
> > ...
> > result = yield from fut
> > return do_stuff(result)
> >
> > Porting from eventlet's implicit async approach to asyncio's explicit
> > async API will be seriously time consuming and we need to be able to do
> > it piece-by-piece.
>
> Am I right in saying that this implies a change to the effective API for
> oslo.messaging[1]? I.e. every invocation on the library, e.g. a call or
> a cast, will need to be changed to be explicitly asynchronous?
>
> [1] Not necessarily a change to the signature of functions, but a change
> to the manner in which they are invoked.
The first step is to patch endpoints to add @trollius.coroutine to the methods,
and add yield From(...) on asynchronous tasks.
Later we may modify Oslo Messaging to be able to call an RPC method
asynchronously, a method which would return a Trollius coroutine or task
directly. The problem is that Oslo Messaging currently hides "implementation"
details like eventlet. Returning a Trollius object means that Oslo Messaging
will use explicitly Trollius. I'm not sure that OpenStack is ready for that
today.
Victor
More information about the OpenStack-dev
mailing list