Python xmlrpclib raise IncompleteRead Error

276 views Asked by At

I have a simple xmlrpc server which is written along the line of

server = SimpleXMLRPCServer(('127.0.0.1', 8000),allow_none=True)
server.register_function(self.fetch_buyer_data,'"fetch_buyer_data")
...
...
server.serve_forever()

This is not the complete code, but you get the idea (hopefully) !

In the same server script, I have a function that reads off the contents of an sqlite3 database and return all the data. Something like this:

def fetch_buyer_data(self, projectname):
    conn = sqlite3.connect(...)
    # read data from sqlite3 database and save it into list
    conn.close()
    return datalist

And I use this following code from client to access the above function.

proxy = xmlrpclib.ServerProxy("http://%s:%s/" %(hostip,hostport),allow_none=True)
data = proxy.fetch_buyer_data(SELECTED_PROJECT)

It's all good until the data in sqlite3 database get larger (not very large but something like a few Megabytes!), I keep getting the following error message!

Traceback (most recent call last):
  File "C:\Custom\src\Client\client.py", line 178, in show_user_page
    userpage = UserPage()
  File "C:\Custom\src\Client\client.py", line 2371, in __init__
    self.update_buyer_table()
  File "C:\Custom\src\Client\client.py", line 6106, in update_buyer_table
    data = proxy.fetch_buyer_data(SELECTED_PROJECT)
  File "C:\Python27\Lib\xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\Lib\xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "C:\Python27\Lib\xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27\Lib\xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "C:\Python27\Lib\xmlrpclib.py", line 1453, in parse_response
    stream = GzipDecodedResponse(response)
  File "C:\Python27\Lib\xmlrpclib.py", line 1204, in __init__
    self.stringio = StringIO.StringIO(response.read())
  File "C:\Python27\Lib\httplib.py", line 548, in read
    s = self._safe_read(self.length)
  File "C:\Python27\Lib\httplib.py", line 649, in _safe_read
    raise IncompleteRead(''.join(s), amt)
httplib.IncompleteRead: IncompleteRead(8031 bytes read, 1732 more expected)

NOTE: I have checked that the rest of the registered functions on server are working. So,I can rule out the connection problems(ip,port etc).

What is casuing this error message? How do I overcome the problem?

I am using python 2.7 on windows xp sp3.

UPDATE 1:

I found out that this doesn't entirely depends on the size of the database. Sometimes it gives me error message, sometimes it doesn't. Could anyone tell me what is casuing this IncompleteRead Problem?

0

There are 0 answers