You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Martin Wilck (JIRA)" <ji...@apache.org> on 2016/04/27 12:53:13 UTC

[jira] [Updated] (THRIFT-3800) Python THttpClient hangs on Oneway methods in the test suite

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

Martin Wilck updated THRIFT-3800:
---------------------------------
    Attachment: 0001-Python-THttpClient-Fix-Oneway-support-for-unit-tests.patch

Suggested patch. Note that this applies on top of my patch for THRIFT-3798 (https://issues.apache.org/jira/secure/attachment/12800981/0001-python-THttpClient-Add-support-for-system-proxy-sett.patch)

> Python THttpClient hangs on Oneway methods in the test suite
> ------------------------------------------------------------
>
>                 Key: THRIFT-3800
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3800
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library, Test Suite
>    Affects Versions: 0.9.3, 1.0
>         Environment: Linux / Python
>            Reporter: Martin Wilck
>              Labels: patch, test
>         Attachments: 0001-Python-THttpClient-Fix-Oneway-support-for-unit-tests.patch
>
>
> The generated python  code for "oneway" methods calls flush() to send the data. The flush() method of THttpClient calls http_client.HTTPCconnection.getresponse(). This hangs forever waiting for a HTTP response from the server, unless a timeout  has been specified, in which case the respective test simply fails. The reason for this is that the HTTP TestServer (C++) does not send a HTTP response for oneway messages (verified this using wireshark with the default "simple" server).
> IMO this is in fact a bug of the TestServer, because the HTTP protocol specification clearly states that the server has to send "one ore more" HTTP response messages in reply to every request message (https://tools.ietf.org/html/rfc7230, 2.1).
> However, the test suite for other languages (C++) works fine with this setup and fails with python.
> Steps to reproduce:
> #  Build thrift with py support
> # Run a HTTP test with cpp server and python client:
> {noformat}
> cd test/py
> ../cpp/TestServer --protocol=compact --transport=http --port=51291 &> /tmp/server.log
> ./TestClient.py --verbose --host=localhost --genpydir=gen-py --protocol=compact --http=/ --port=51291
> {noformat}
> *Result:* the client hangs forever in the "testOneway" test. When killed with ctrl-c, it can be seen to hang in the following call stack:
> {noformat}
> ...
>   File "test/py/gen-py/ThriftTest/ThriftTest.py", line 1070, in testOneway
>     self.send_testOneway(secondsToSleep)
>   File "test/py/gen-py/ThriftTest/ThriftTest.py", line 1078, in send_testOneway
>     self._oprot.trans.flush()
>   File "lib/py/build/lib.linux-x86_64-2.7/thrift/transport/THttpClient.py", line 129, in _f
>     result = f(*args, **kwargs)
>   File "lib/py/build/lib.linux-x86_64-2.7/thrift/transport/THttpClient.py", line 168, in flush
>     self.__http_response = self.__http.getresponse()
>   File "/usr/lib64/python2.7/httplib.py", line 1067, in getresponse
>     response.begin()
>   File "/usr/lib64/python2.7/httplib.py", line 409, in begin
>     version, status, reason = self._read_status()
>   File "/usr/lib64/python2.7/httplib.py", line 365, in _read_status
>     line = self.fp.readline(_MAXLINE + 1)
>   File "/usr/lib64/python2.7/socket.py", line 476, in readline
>     data = self._sock.recv(self._rbufsize)
> {noformat}
> *Expected Result:* Success.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)