[Twisted-Python] Twisted and PEP 3148 support

Alex Grönholm alex.gronholm at nextday.fi
Mon Jan 10 16:57:14 EST 2011


There has been some discussion over email between myself and several 
Twisted developers regarding the possibility of adding support for PEP 
3148 futures and executors to Twisted. I'm starting this thread to move 
the conversation to this mailing list to gain a broader audience.

For those who do not know what PEP 3148 is about, suffice to say that 
it's an API for deferred execution of code. The reference implementation 
can be found in the Python 3.2 standard library under the package name 
concurrent.futures. A backport that works on Python 2.5, 2.6, 2.7 and 
3.1 has been made available by Brian Quinlan and myself and is available 
for download at the Python Package Index.

A brief summary of the email conversations:

* The purpose of integrating PEP 3148 support is the intended shift 
towards a common API for creating asynchronous applications
* Deferreds and Futures are alike in purpose but very different under 
the hood
* Support for the Futures API cannot be integrated directly to Deferreds 
because of the "result" attribute which is a method in Future but a 
value in Deferred
* Some people suggested wrapping Futures in Deferreds, though I have yet 
to hear a rationale for this
* PEP 3148 executor support could be directly integrated to Twisted's 
thread pools (and by extension, reactors) as there are no naming 
conflicts that I'm aware of

The main focus of the discussion is to figure out how to best integrate 
support for this new API to Twisted. If possible, existing protocols 
should remain compatible through the use of adapters or some other 
mechanism. If not, a way to port them over with a minimal amount of work 
would be the next target.



More information about the Twisted-Python mailing list