Skip to content
Some examples of how the Twisted Deferred class' chainDeferred might be improved
Python
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README
boom1.py
boom2.py
tdefer.py
uncalled.py
unexpected1.py
unexpected2.py

README

Here are some commented examples of how the chainDeferred method in
Twisted's Deferred class can be a bit surprising, or cause errors, or
perhaps even dangerous (not calling cancel on chained deferreds).

There's an alternate Deferred class in tdefer.py that shows one way we
might go about addressing these issues. Note that it's not suggested as a
perfect solution, just a possible direction. Deferreds are complicated and
the tdefer.py class probably gets things wrong in some cases. So tdefer.py
is just a pointer to how we might do things, intended to start discussion.
(tdefer.py is based on Twisted 10.1)

To run an example using normal deferreds, invoke it using Python from the
command line. E.g.,

    $ python uncalled.py
    cancel one
    cancelled one

To run with tdefer.py add an argument (anything at all):

    $ python uncalled.py xxx
    cancel one
    cancelled one
    cancel two
    cancelled two


Terry Jones
terry@fluidinfo.com
http://twitter.com/terrycojones
Something went wrong with that request. Please try again.