lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Database.view() and list() don't work on Google's AppEngine #224

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. setup a python appengine env
2. use the list() or view() functions
3.

What is the expected output? What do you see instead?
The script get stuck on list() (or when you want iterate the result of view())

I think it is getting stuck on conn.getresponse() in http._try_request() 

What version of the product are you using? On what operating system?
0.9

Please provide any additional information below.

Original issue reported on code.google.com by alexan...@codjovi.fr on 20 May 2013 at 7:11

GoogleCodeExporter commented 8 years ago
After some investigation
The problem is inside http:ResponseBody::close

the test below leads to an infinite loop  
while not self.resp.isclosed():
            self.resp.read(CHUNK_SIZE)

the httplib documentations says:

def isclosed(self):
        # NOTE: it is possible that we will not ever call self.close(). This
        #       case occurs when will_close is TRUE, length is None, and we
        #       read up to the last byte, but NOT past it.
        #
        # IMPLIES: if will_close is FALSE, then self.close() will ALWAYS be
        #          called, meaning self.isclosed() is meaningful.
        return self.fp is None

AppEngine uses a custome version of httplib.

I dont know its behavior. But it returns True with the standard httplib and 
False on app engine (and makes an infinite loop)

Original comment by alexan...@codjovi.fr on 20 May 2013 at 9:55

GoogleCodeExporter commented 8 years ago
here my fix

def close(self):
        while not self.resp.isclosed():
            chunk =  self.resp.read(CHUNK_SIZE)
            if len(chunk) == 0:
                self.resp.close()
        if self.callback:
            self.callback()
            self.callback = None

Original comment by alexan...@codjovi.fr on 20 May 2013 at 10:27

GoogleCodeExporter commented 8 years ago
This issue has been migrated to GitHub. Please continue discussion here:

https://github.com/djc/couchdb-python/issues/224

Original comment by djc.ochtman on 15 Jul 2014 at 7:22