Seeing exceptions from methods registered to SimpleXMLRPCServer

可紊 提交于 2021-02-19 05:53:08

问题


I'm writing an xmlrpc-based python 2.7 program, using SimpleXMLRPCServer. I import the class with all our logic and register it with:

server = SimpleXMLRPCServer(("0.0.0.0", 9001))
server.register_instancce(classWithAllTheLogic())
server.serve_forever()

When running this in console I can see the log messages from SimpleXMLRPCServer about what messages are being sent, but all of the debug information from methods within classWithAllTheLogic() seems to be surpressed. If a method throws an exception there, I don't see any error message in console, and the xmlrpc call bound to that method just silently fails. print statements within the classWithAllTheLogic methods also just don't show up. What's going on here?


回答1:


I am unable to reproduce this. Test script test.py

from xmlrpc.server import SimpleXMLRPCServer
class classWithAllTheLogic:
    def __init__(self):
        print("Hi")
        raise Exception("INIT Exception")

    def hello(self):
        print("hello")
        raise Exception("Hello Exception")

server = SimpleXMLRPCServer(("0.0.0.0", 9001))
server.register_instance(classWithAllTheLogic())
server.serve_forever()

Run:

E:\tmp>python test.py
Hi
Traceback (most recent call last):
  File "test.py", line 13, in <module>
    server.register_instance(classWithAllTheLogic())
  File "test.py", line 6, in __init__
    raise Exception("INIT Exception")
Exception: INIT Exception

E:\tmp>

?!



来源:https://stackoverflow.com/questions/7779910/seeing-exceptions-from-methods-registered-to-simplexmlrpcserver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!