[Twisted-Python] unhandled exception in deferred has a delayed logging ?
itamar at futurefoundries.com
Wed Sep 26 20:20:46 EDT 2012
On Wed, Sep 26, 2012 at 7:46 PM, Jonathan Vanasco
<twisted-python at 2xlp.com>wrote:
> while migrating some functionality to a deferred callback chain and
> debugging my app, i noticed this oddity...
> if a function doesn't have the proper args/kwargs definition, no error is
> raised and everything just hangs
> then the reactor just seems to hang.
> if i kill the process, then the Unhandled Error and Traceback message
> If i wait until the next interval that the timerservice runs, then the
> Unhandled Error and Traceback message will print then ( but that could be
> minutes/hours later ).
> has anyone else noticed this before ?
The reactor isn't hanging, it's running just fine. The problem is you
expect the Deferred's error to be logged immediately, which is not
guaranteed; the error is only logged if the object is garbage collected,
which may take a while, or never happen if you've kept extra references
around. The latter can happen by accident.
> are there any good ways around this , other than setting the timer service
> to be within seconds during bugtesting ?
1. Add a logging errback to all Deferreds at the end of the callback
2. Less effective, but also helpful, is making sure you delete all
unnecessary references to a Deferred once you've fired it, to make sure it
gets garbage collected:
del self.d # remove extra reference that prevents garbage collection
http://bit.ly/NS6ptj explains the issue.
Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python