Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
0.9.3
-
None
-
Linux / Python
-
Patch Available
Description
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:
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
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:
... 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)
Expected Result: Success.