which async framework?
tjreedy at udel.edu
Tue Mar 11 20:41:30 CET 2014
On 3/11/2014 3:53 AM, Chris Withers wrote:
> On 10/03/2014 21:57, Terry Reedy wrote:
>>> I'd like to be able to serve the rest of the web api using a pyramid
>>> wsgi app if possible, and I'd like to be able to write the things that
>>> process requests in and validation out in a synchronous fashion, most
>>> likely spinning off a thread for each one.
>> If you are writing 'standard' blocking, synchronous code, I am not sure
>> why you would use any of the above.
> The idea I have is to do all the networking async based on a declarative
> set of messages in and recording all messages out and then hand that set
> of messages off to a syncronous layer to make assertions, record into a
> database, etc.
In the absence of an event-loop oriented queue, putting jobs on a thread
queue for a job-handler makes sense.
>>> The protocols are all financial (do we really not have a pure-python FIX
>>> library?!) but none are likely to have existing python implementations.
>>> How should I pick between the options? What would people recommend and
>> I know nothing of tornado. I personally would use asyncio over twisted
>> if I could because it is simpler, in the stdlib, has the option to write
>> 'untwisted' non-blocking code similar to blocking code, and the docs
>> easier for me to read.
> Guess I was expecting more of a response.
Let me try again. I read the Twisted docs a couple of years ago. While
I could deal with the interface, I understand why it is called 'twisted'
and why Guido does not particularly like it. I read the asyncio doc
before the most recent revisions and found it easier to understand. I
personally like the co-routine layer. But I know that this is very much
a personal preference. (Sturla just confirmed this by posting the
opposite response to the coroutine interface.) So I suggest you spend an
hour with the doc for each of the three candidates.
> I suspect I'll just end up cross-posting to the various mailing lists,
Bad idea. Post separately if you must.
> which I hope won't cause too much offence or kick off any flame wars.
It would do both.
> I'm faced with a difficult choice that I suspect many in our community
> are, just trying to find out how to make the best decision :-)
The asyncio event loop interface was designed with knowledge of other
event loops, including but not limited to those of twisted and tornado.
The implementation in asyncio is intended to be replaceable by other
implementations that include the same interface. I do not know if there
are adapters yet for the twisted and tornado loops, but I expect there
will be, official or not. Part of Guido's intent is to reduce
single-framework lockin. If you start with asyncio, and decide you want
to use some Twisted protocols, you should be able to (at least in the
future) without dumping your current code.
Terry Jan Reedy
More information about the Python-list