On Wed, Mar 12, 2014 at 5:41 AM, Luca Sbardella <luca.sbarde...@gmail.com>wrote:

> On 12 March 2014 07:28, Chris Withers <ch...@simplistix.co.uk> wrote:
>
>>
>> So, I see python now has a plethora of async frameworks and I need to try
>> and pick one to use from:
>>
>> - asyncio/tulip
>> - tornado
>> - twisted
>>
>> From my side, I'm looking to experimentally build a network testing tool
>> that will need to speak a fair few protocols, both classic tcp and
>> multicast-based, and have a web api living on top of it that most likely
>> will have a websocket for pumping data to the browser. It'll also need to
>> write out JUnit-compatible xml results, but that's like the easiest bit ;-)
>>
>> 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.
>>
>
> Tornado is a web-framework, if you are going to use pyramid for handling
> wsgi requests asyncio or twisted are probably a better solution. They can
> handle your synchronous wsgi responses via the event loop executor (a
> thread pool).
>

Tornado is not just a web framework - you can use IOStream and the other
lower-level components to implement other protocols.  On the other hand, it
doesn't have built-in support for anything but TCP - if you need e.g. UDP
you'll have to build your own abstractions from the underlying socket APIs.
 This may be a good or bad thing depending on your experience.  Tornado's
WSGI support is also not that great, so if the choice of pyramid (vs
tornado.web) is important to you you might be better off with one of the
other frameworks.


>
>
>>
>> The protocols are all financial (do we really not have a pure-python FIX
>> library?!) but none are likely to have existing python implementations.
>>
>
> Both asyncio and twisted offer an extensive, somehow similar, API for
> writing protocols, TCP and UDP.
>
>
>> How should I pick between the options? What would people recommend and
>> why?
>>
>>
>
Twisted is by far the most comprehensive, both in its platform support and
the breadth of its networking options (built-in and third-party), but it's
not available yet on Python 3.  Asyncio is young and there's not much
third-party code available for it yet, but its standard-library status
gives it a promising future.  It's a good choice as long as you're on
Python 3 (trollius makes asyncio itself available on python 2, but I expect
most third-party libraries that target asyncio will be Python 3-only).
 Tornado is more narrowly-focused (biased towards posix, tcp, and http),
but many people have found its interfaces easier to learn and work with
than twisted (YMMV of course).

-Ben

Reply via email to