I have a python object whose methods are currently being exposed via XML-RPC using the standard xmlrpc.server.SimpleXMLRPCServer (with the ThreadingMixIn, but that should not be relevant).
The server is running on Win64 as are the clients. Some RPC methods return tables of information from a database to the client. I'm finding that even modest blocks of data are overwhelming the OS and I get this kind of error:
Traceback (most recent call last): File "C:\Python32\lib\wsgiref\handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "U:\Me\src\application\my_xmlrpc_client.py", line 1510, in __call__ body = method(environ, start_response) File "U:\Me\src\application\my_xmlrpc_client.py", line 305, in q_root rows = proxy.return_table() File "C:\Python32\lib\xmlrpc\client.py", line 1095, in __call__ return self.__send(self.__name, args) File "C:\Python32\lib\xmlrpc\client.py", line 1423, in __request verbose=self.__verbose File "C:\Python32\lib\xmlrpc\client.py", line 1136, in request return self.single_request(host, handler, request_body, verbose) File "C:\Python32\lib\xmlrpc\client.py", line 1151, in single_request return self.parse_response(resp) File "C:\Python32\lib\xmlrpc\client.py", line 1323, in parse_response return u.close() File "C:\Python32\lib\xmlrpc\client.py", line 667, in close raise Fault(**self._stack[0]) xmlrpc.client.Fault: :[Errno 12] Not enough space"> LIBRA.rsvfx.com - - [19/May/2011 15:58:09] "GET / HTTP/1.1" 500 59
Some research into the Errno 12 problem reveals that there's some issue with the underlying MS OS call and not with python itself: http://bugs.python.org/issue11395
I'm not a very experienced XML-RPC developer; but is there some standard convention I should follow for delivering large payloads which would result in more, smaller writes (as opposed to fewer, large writes)?
And please remember I'm asking about buffer overruns; I don't want to have to debate why I'm using XML-RPC rather than rolling my own RESTful interface... I had to patch my WSGI application for this problem - sending small 1k blocks rather than larger blocks. I'm not sure how to patch the XML-RPC application.
-- edit --
As requested, here is a code sample that reproduces the problem:
import xmlrpc.server class RPCApp : def get_page(self): return ["data" * 64 for i in range(0,1024)] if __name__ == '__main__' : # important to use this block, for processes to spawn correctly server = xmlrpc.server.SimpleXMLRPCServer(('127.0.0.1',8989), allow_none=True, logRequests=False) server.register_instance(RPCApp()) server.serve_forever()
And the client code:
import xmlrpc.client proxy = xmlrpc.client.ServerProxy('http://127.0.0.1:8989', allow_none=True) print(proxy.get_p开发者_Python百科age())
If you manipulate the page in the server to be small, then the code works. As it is, the exception is thrown.
-- edit --
Seems to be resolved in python 3.2.1rc1. Looks like we'll have to upgrade our installation....
精彩评论