How to Catch Errors in SimpleXMLRPCServer
Jeff McNeil
jeff at jmcneil.net
Thu Sep 27 15:56:27 EDT 2007
getattr, not self.getattr.
On 9/27/07, Jeff McNeil <jeff 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.
>
> -Jeff
>
> On 9/27/07, gregpinero at gmail.com <gregpinero at gmail.com> wrote:
> > I have a pretty simple XMLRPCServer, something along the lines of the
> > example:
> >
> > server = SimpleXMLRPCServer(("localhost", 8000))
> > server.register_function(pow)
> > server.register_function(lambda x,y: x+y, 'add')
> > server.serve_forever()
> >
> > Now what I want to do is catch any errors that happen on requests, and
> > ideally have them emailed to me. I have the email part all taken care
> > of, I just need to know how to get at the exceptions.
> >
> > Thanks in advance for any help,
> >
> > Greg
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
More information about the Python-list
mailing list