From 4db14a7237443429a5cd6701bd7a37b1ba939e56 Mon Sep 17 00:00:00 2001 From: Uri Laserson Date: Thu, 4 Feb 2016 14:28:51 -0800 Subject: [PATCH] fix set_timeout backwards compatibility Then given `None` as a timeout value, the set_timeout method would not actually set the timeouts to `None`. This would leave the values at 3 s if the `TSocket` object was instantiated with default args. This change ensures that calling `set_timeout(None)` really sets the timeouts to `None`. --- thriftpy/transport/socket.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/thriftpy/transport/socket.py b/thriftpy/transport/socket.py index 8410259..7958425 100644 --- a/thriftpy/transport/socket.py +++ b/thriftpy/transport/socket.py @@ -75,9 +75,8 @@ def set_timeout(self, ms): """Backward compat api, will bind the timeout to both connect_timeout and socket_timeout. """ - if ms and ms > 0: - self.socket_timeout = ms / 1000 - self.connect_timeout = self.socket_timeout + self.socket_timeout = ms / 1000 if (ms and ms > 0) else None + self.connect_timeout = self.socket_timeout def is_open(self): return bool(self.sock)