[openstack-dev] [solum] async / threading for python 2 and 3

Victor Stinner victor.stinner at enovance.com
Fri Feb 21 10:03:31 UTC 2014


Le vendredi 21 février 2014, 09:27:49 Angus Salkeld a écrit :
> >Honestly, I have no answer to your question right now ("How useful is
> >trollius ...").
> >(...) 
> >I asked your question on Tulip mailing list to see how a single code base
> >could support Tulip (yield from) and Trollius (yield). At least check if
> >it's technically possible.

Short answer: it's possible to write code working on Trollius (Python 2 and 3) 
/ Tulip (Python 3.3+) / CPython 3.4 (asyncio) if you use callbacks. The core 
of the asyncio module (event loop and scheduler) uses callbacks. If you only 
uses callbacks, you can also support Twisted and Tornado frameworks.

For example, the AutobahnPython project adopted this design and thanks to 
that, it supports Trollius, Tulip and CPython asyncio, but also Twisted:

    https://github.com/tavendo/AutobahnPython

So you have to find a WSGI server using callbacks instead of "yield from". It 
should not be hard since asyncio is young, callbacks was the only option 
before greenlet/eventlet, and Twisted and Tornado (which use callbacks) are 
still widely used.

Victor



More information about the OpenStack-dev mailing list