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 6 1885 gr********@gmail.com a écrit :
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.
Q&D :
try:
server.serve_forever()
except Exception, e:
mail_me_the_exception(e)
raise
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, gr********@gmail.com <gr********@gmail.comwrote:
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
getattr, not self.getattr.
On 9/27/07, Jeff McNeil <je**@jmcneil.netwrote:
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, gr********@gmail.com <gr********@gmail.comwrote:
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
On Sep 27, 3:55 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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
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, gr********@gmail.com <gr********@gmail.comwrote:
On Sep 27, 3:55 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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
On Sep 27, 5:08 pm, "Jeff McNeil" <j...@jmcneil.netwrote:
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()
Thanks, that works. I'm not sure why I didn't notice it wasn't
returning anything.
-Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas G. Apostolou |
last post by:
Hello all,
I use Python 2.3.3 and try to patch SimpleXMLRPCServer.py with the patch i
got from Python.org.
so after changing to the directory where both SimpleXMLRPCServer.py and...
|
by: JDF |
last post by:
I am trying to create a Windows service using SimpleXMLRPCServer and
win32serviceutil. The service itself seems to be working properly
(starts, stops, etc) and I can connect using an XMLRPC client...
|
by: Achim Domma |
last post by:
Hi,
is SimpleXMLRPCServer multithreaded or how does it handle multiple
clients? I want to implement a simple server which will be queried by
multiple processes for work to be done. The server...
|
by: getafixx |
last post by:
Hello everyone,
We have a linux server (Fedora core 7, default install, firewall turned off) and a bunch of windows XP machines on network/domain.
All machines are visible and I can get to both...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |