How to Catch Errors in SimpleXMLRPCServer
Jeff McNeil
jeff at jmcneil.net
Thu Sep 27 17:08:17 EDT 2007
Yeah, that code was out of memory and I didn't test it, my apologies.
Need to actually return a value from _dispatch.
class MyCalls(object):
def _dispatch(self, method, args):
try:
return getattr(self, method)(*args)
except:
handle_logging()
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(MyCalls())
server.serve_forever()
-Jeff
On 9/27
On 9/27/07, gregpinero at gmail.com <gregpinero at gmail.com> wrote:
> On Sep 27, 3:55 pm, "Jeff McNeil" <j... at jmcneil.net> wrote:
> > Instead of register_function, use register_instance and provide a
> > _dispatch method in that instance that handles your exception logging.
> >
> > Pseudo:
> >
> > class MyCalls(object):
> > def _dispatch(self, method, args):
> > try:
> > self.getattr(self, method)(*args)
> > except:
> > handle_logging()
> >
> > server = SimpleXMLRPCServer(("localhost", 8000))
> > server.register_instance(MyCalls())
> > server.serve_forever()
> >
> > There might be an easier way... but this works for me.
>
> I wonder if there is something wrong with that. I get this error on
> calling ever method:
>
> Fault 1: 'exceptions.TypeError:cannot marshal None unless allow_none
> is enabled' but I can't see anywhere None would be coming from.
>
> -Greg
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list