我有简单的 xmlrpc 服务器代码:
from SimpleXMLRPCServer import SimpleXMLRPCServer
port = 9999
def func():
print 'Hi!'
print x # error!
print 'Bye!'
if __name__ == '__main__':
server = SimpleXMLRPCServer(("localhost", port))
print "Listening on port %s..." % port
server.register_function(func)
server.serve_forever()
示例会话。
客户:
>>> import xmlrpclib
>>> p = xmlrpclib.ServerProxy('http://localhost:9999')
>>> p.func()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "C:\Python26\lib\xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "C:\Python26\lib\xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "C:\Python26\lib\xmlrpclib.py", line 1392, in _parse_response
return u.close()
File "C:\Python26\lib\xmlrpclib.py", line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.NameError'>:global name 'x' is not defined">
>>>
服务器:
Listening on port 9999...
Hi!
localhost - - [11/Jan/2011 16:17:09] "POST /RPC2 HTTP/1.0" 200 -
问题是我是否也可以在服务器上获取此跟踪。我需要知道处理查询是否出现问题。我没有使用用 Python 编写的客户端,所以我很难像上面那样进行回溯。