You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "David Reiss (JIRA)" <ji...@apache.org> on 2009/03/24 21:11:50 UTC

[jira] Resolved: (THRIFT-155) Python THttpClient should handle opening HTTP layer on each request automatically

     [ https://issues.apache.org/jira/browse/THRIFT-155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss resolved THRIFT-155.
--------------------------------

    Resolution: Fixed
      Assignee: Dave Engberg

> 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
>            Assignee: 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.