[Twisted-Python] Flow, generators, coroutines etc.

Jean-Paul Calderone exarkun at divmod.com
Sun May 28 10:13:23 EDT 2006


On Sun, 28 May 2006 11:45:22 +0100, Dominic Fox <dominic.fox at gmail.com> wrote:
>I understand that twisted.flow is no longer maintained, and is not
>widely considered to represent a good way of writing twisted code.
>However, I haven't been able to find any explanation of why this
>approach (using generators to simulate co-operative multitasking)
>seems to have been abandoned.

Flow added a lot of complexity which served no great purpose.  Roughly
the same thing can be achieved in a tiny fraction of the code and API
size using twisted.internet.defer.deferredGenerator.

So it's not that the approach was abandoned, it's that a particular
implementation of it was abandoned.

I should also point out that Flow has almost nothing to do with
cooperative multitasking (and certainly nothing to do with
simulating it).  Twisted is a cooperative multitasking system at
the lowest level.  Everything you write with Twisted is an application
of cooperative multitasking.

Flow and Deferred Generators are different APIs for yielding
execution control, ones which often allow code which uses
asynchronous APIs to be written in a way which makes them appear
to be using synchronous APIs.

Inasmuch as this is misleading to readers, there is some debate
over whether or not it is a good idea at all.  However, Deferred
Generator is around and will be supported for some time.

Jean-Paul




More information about the Twisted-Python mailing list