[Twisted-Python] deferred graph?

Andrew Bennetts andrew at bemusement.org
Wed Jul 18 17:51:19 MDT 2012


Dan Stromberg wrote:
> On Wed, Jul 18, 2012 at 3:32 AM, <exarkun at twistedmatrix.com> wrote:
> >
> > I don't think anything in the thread suggested that this approach will
> > circumvent a time.sleep(10) call.
> 
> I'm not sure where you're getting this circumvention issue from.

At this point I'm not sure what the problem you're trying to solve is.

To look at this from another direction… here's the built-in facilities in
Twisted for debugging what's happening with Deferreds:

 - Deferred's __str__ and __repr__ summarises the key state (i.e. has this been
   fired, is this waiting on another Deferred).
 - unhandled errors of GC'd Deferreds triggers an “Unhandled error” log
   message, to let you know that your code is probably missing something it
   should act on.  Due to the nature of GC this is a best effort feature,
   there's no guarantee it will fire reliably or at all.
 - you can setDebugging(True) to have Twisted capture more information to
   include in the above log message: the traceback for what created the
   Deferred, and the traceback that initially called it.  This is very helpful
   for helping you pinpoint which parts of your code are failing to add an
   errback.
 - as a bonus, because this is Python, you can abuse the private variables used
   to implement the previous points for your own ad hoc debugging, if you are ok
   with the fact that they are undocumented and unsupported APIs.

And that's basically it.  (If I've forgotten something I'm sure someone will
reply to remind me.)

It sounds like you're looking for something else, but I'm not sure quite what.
Something roughly along the lines of “what are all the live Deferreds in my
process?” maybe?

-Andrew.





More information about the Twisted-Python mailing list