[Twisted-Python] Another example of using generators in Twisted
Donovan Preston
dp at twistedmatrix.com
Fri Sep 20 12:36:06 MDT 2002
Here's an example of using generators to make long chains of deferreds
easier to deal with. Using the function unwrapDeferredGenerator on a
generator object will cause the generator to be run until it yields
None. Each time the generator yields a deferred, the function is halted
and resumed when the Deferred fires. The result of the Deferred is
available in deferred.result.
What used to be a long chain of callback functions can now be written
as one generator function, (hopefully) making things easier to read.
Donovan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yielddeferreds.py
Type: application/applefile
Size: 471 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020920/329e2472/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yielddeferreds.py
Type: application/text
Size: 1043 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20020920/329e2472/attachment-0005.bin>
More information about the Twisted-Python
mailing list