[Twisted-Python] Re: Traceback from pb-Server

David Bolen db3l at fitlinxx.com
Thu Jun 23 15:17:38 MDT 2005


Stephan Popp <Stephan.Popp at iisb.fraunhofer.de> writes:

> If the pythonscript named taskDescription.fileName isn't there 
> self.serverErrorCB is called - thats ok. But it prints:
> reason [Failure instance: Traceback from remote host -- Traceback unavailable]
> 
> But I need to know why the call failed. Can anyone please help me to get the 
> traceback or the exception message that the server prints 
> (exceptions.ImportError: No module named fitfunc2).

The returned Failure instance should still encapsulate the underlying
exception information in the type and value fields, as is usual with
Failure objects.  One difference from a local Failure instance though
is that type will be a string representation of the exception class
and not the class object itself in the PB client context.  If you
stick with failure.trap() and failure.check() for explicit exception
checks in errback chains, they handle both the direct class as well as
string version, so errback code will work locally or via a PB client.

So you can still identify the root exception (ImportError).  It just
happens to not show up in the default __str__ output for the failure
object (e.g., your print in your errback) but if you were to modify
that print to explicitly print out the type and value fields, and not
just let the failure object generate its own printable format, you can
see the information.  And checking for an exception itself rather than
looking for textual information in a traceback is probably better for
production code.

If you really want to see the traceback during development/debugging,
you should see them output as a log message on the server side (if you
have twisted logging going somewhere).  Alternatively, I believe you
can enable "unsafe" tracebacks (which sends the traceback to remote
clients) by setting the unsafeTracebacks attribute in the factory on
the side on which the exception is being generated - the
PBServerFactory side in your case.  For PBServerFactory, it's an
optional argument to the constructor.

-- David





More information about the Twisted-Python mailing list