Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Patch Available
Description
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()
Attachments
Attachments
Issue Links
- causes
-
THRIFT-4600 Don't close the connection in flush for python THttpClient.py
- Open