[ https://issues.apache.org/jira/browse/THRIFT-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12637773#action_12637773 ]
David Reiss commented on THRIFT-155: ------------------------------------ I think that with an http lib that doesn't expose low-level connection information, we should make isOpen always true, make open and close no-ops, and do all of the setup in flush instead of open. Votes? We can definitely have a second http transport based on a non-standard library that exposes more implementation details. > Python THttpClient should handle opening HTTP layer on each request > automatically > --------------------------------------------------------------------------------- > > Key: THRIFT-155 > URL: https://issues.apache.org/jira/browse/THRIFT-155 > Project: Thrift > Issue Type: Improvement > Components: Library (Python) > Reporter: Dave Engberg > Attachments: THttpClient.py.diff > > > The HTTP transport for other languages (like Java) will automatically open > the HTTP connection on each Thrift message in the flush() method. > The Python THttpClient requires you to explicitly call .open() on the > low-level transport before every Thrift invocation. If you don't do this, > you'll get a "ResponseNotReady" error out of httplib: > ... > self._oprot.trans.flush() > File > "/Users/dave/dev/work/en-thrift/target/evernote-api-1.10/lib/python/thrift/transport/THttpClient.py", > line 60, in flush > self.code, self.message, self.headers = self.__http.getreply() > File > "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/httplib.py", > line 1195, in getreply > response = self._conn.getresponse() > File > "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/httplib.py", > line 914, in getresponse > raise ResponseNotReady() > httplib.ResponseNotReady > I'm submitting a small patch to THttpClient.py that will automatically handle > the opening of the required low-level HTTP connection with each Thrift > message in the beginning of the flush() method: > Index: lib/py/src/transport/THttpClient.py > =================================================================== > --- lib/py/src/transport/THttpClient.py (revision 701711) > +++ lib/py/src/transport/THttpClient.py (working copy) > @@ -37,6 +37,10 @@ > self.__wbuf.write(buf) > > def flush(self): > + if self.isOpen(): > + self.close() > + self.open(); > + > # Pull data out of buffer > data = self.__wbuf.getvalue() > self.__wbuf = StringIO() -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.