[Twisted-Python] Re: flow.Zip
Clark C. Evans
cce at clarkevans.com
Wed Apr 23 11:48:23 EDT 2003
Actually, the diagram isn't quite right. Here is a better one.
Suppose you have generator X -> Y -> Z, the picture
then looks like...
Wrap <-- Z
Wrap <-- Y
Wrap <-- X
| So, rather than X talking to Y, talking to Z, each of
| your generators is talking to a wrapper instead, which
| tries to be as transparent as possible. The
| wrapper has the following behavior:
| 0. If a value is returned from a generator to
| a wrapper, it is given to the previous generator
| in the chain; at the bottom of the chain it is
| added to an array which is sent to the deferred's
| callback. Failures are handled the same way.
| 1. If the value returned is a wrapper, then it adds
| the new wrapper to the top of the stack and
| starts to process it.
| 2. When Cooperate is returned from a generator,
| it is sent all the way down the Wrapper linked
| list so that the reactor can re-schedule the
| processing chain (micro-thread).
More information about the Twisted-Python