[Twisted-Python] unhandled exception in deferred has a delayed logging ?
twisted-python at 2xlp.com
Wed Sep 26 22:47:06 EDT 2012
thanks so much for the quick response, and i wish i thought of looking in the FAQ ( just searched online, and nothing relevant came up )
Will defer.setDebugging(True) make these errors print/log sooner ? i'm in the process of getting all the addErrback() commands and making this app "proper", which is how i found this out in the first place.
On Sep 26, 2012, at 8:20 PM, Itamar Turner-Trauring wrote:
> 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 prints.
> 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 ?
> • Add a logging errback to all Deferreds at the end of the callback chain: d.addErrback(log.err).
> • 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.
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
// Jonathan Vanasco
c. 646.729.6436 | 415.501.9815
e. jonathan at 2xlp.com
More information about the Twisted-Python