Proper display of XMLRPCserver exceptions

Jean-Michel Pichavant jeanmichel at
Mon Jan 18 16:07:56 CET 2010

To all using xmlrpclib,

I had trouble getting a proper display of my exceptions occuring on the 
server. Basically, xmlrpclib only display the exception itself without 
any traceback, on the client side.

Something like
<Fault 1: "<type 'exceptions.KeyError'>:2">

Ok then there's a key error, but how the hell am I supposed to know 
where it occured ?

So I wrote this:
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(('localhost', 8000), logRequests=False, 
old_dispatch = server._dispatch
def _new_dispatch(method, params):
        return old_dispatch(method,params)
    except Exception, exc:
        import traceback
server._dispatch = _new_dispatch

Pretty dirty, isn't it, accessing the private attributes (too lazy to 
subclass) ! I guess there's an obvious way to do this with xmlrpclib 
that I just missed. Anyone knows ?


More information about the Python-list mailing list