[Twisted-Python] Handling errors when using deferToThread
psanchez at nortel.com
Fri Oct 28 11:25:32 EDT 2005
On Sat, 2005-29-10 at 00:56 +1000, Andrew Bennetts wrote:
> On Fri, Oct 28, 2005 at 10:35:08AM -0400, Pedro Sanchez wrote:
> > This works well as long as doLongCalculation() doesn't fail for
> > any reason. But if it does, how can it trigger an errBack?
> Just raise an exception.
> > I want to do something like this:
> > from twisted.internet import threads
> > def doLongCalculation():
> > try:
> > # .... do long calculation here ...
> > except:
> > < what can I return here to tell that
> > the calculation failed? >
> > return 3
> The literal answer here is a bare raise statement. But better would be to
> not use the try-except at all.
Why? What's the alternative?
> Try inserting something like "1/0" into doLongCalculation and see what
I don't understand your "1/0" suggestion. Can you elaborate a bit?
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python