我正在使用SimpleXMLRPCServer编写一个基于xmlrpc的python2.7程序。我用我们所有的逻辑导入类,并用以下命令注册它:
server = SimpleXMLRPCServer(("0.0.0.0", 9001))
server.register_instancce(classWithAllTheLogic())
server.serve_forever()当在控制台中运行时,我可以看到来自SimpleXMLRPCServer的关于正在发送的消息的日志消息,但是来自classWithAllTheLogic()中的方法的所有调试信息似乎都被抑制了。如果某个方法在那里抛出异常,我在控制台中看不到任何错误消息,绑定到该方法的xmlrpc调用就会静悄悄地失败。classWithAllTheLogic方法中的打印语句也不会出现。这里发生了什么事?
发布于 2011-10-20 05:35:07
我不能重现这个。测试脚本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()运行:
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
复制相似问题