THRIFT-5777: python fix mismatched timeout exceptions
Client: ["python"]
diff --git a/lib/py/test/test_socket.py b/lib/py/test/test_socket.py
index b732653..ab56a6e 100644
--- a/lib/py/test/test_socket.py
+++ b/lib/py/test/test_socket.py
@@ -11,6 +11,24 @@
class TSocketTest(unittest.TestCase):
+ def test_socket_readtimeout_exception(self):
+ acc = ServerAcceptor(TServerSocket(port=0))
+ acc.start()
+
+ sock = TSocket(host="localhost", port=acc.port)
+ sock.open()
+ sock.setTimeout(1)
+ sock.write(b"sleep")
+
+ with self.assertRaises(TTransportException) as ctx:
+ sock.read(5)
+ exc = ctx.exception
+ self.assertEqual(exc.message, "read timeout")
+
+ acc.client.close() # this also blocks until the other thread is done
+ acc.close()
+ sock.close()
+
def test_isOpen_checks_for_readability(self):
# https://docs.python.org/3/library/socket.html#notes-on-socket-timeouts
# https://docs.python.org/3/library/socket.html#socket.socket.settimeout