首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查看注册到SimpleXMLRPCServer的方法的异常

查看注册到SimpleXMLRPCServer的方法的异常
EN

Stack Overflow用户
提问于 2011-10-16 02:49:18
回答 1查看 283关注 0票数 2

我正在使用SimpleXMLRPCServer编写一个基于xmlrpc的python2.7程序。我用我们所有的逻辑导入类,并用以下命令注册它:

代码语言:javascript
复制
server = SimpleXMLRPCServer(("0.0.0.0", 9001))
server.register_instancce(classWithAllTheLogic())
server.serve_forever()

当在控制台中运行时,我可以看到来自SimpleXMLRPCServer的关于正在发送的消息的日志消息,但是来自classWithAllTheLogic()中的方法的所有调试信息似乎都被抑制了。如果某个方法在那里抛出异常,我在控制台中看不到任何错误消息,绑定到该方法的xmlrpc调用就会静悄悄地失败。classWithAllTheLogic方法中的打印语句也不会出现。这里发生了什么事?

EN

回答 1

Stack Overflow用户

发布于 2011-10-20 05:35:07

我不能重现这个。测试脚本test.py

代码语言:javascript
复制
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()

运行:

代码语言:javascript
复制
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>

?!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7779910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档