Fix timeout handling in LUXI client
authorMichael Hanselmann <hansmi@google.com>
Mon, 20 Dec 2010 19:20:18 +0000 (20:20 +0100)
committerMichael Hanselmann <hansmi@google.com>
Mon, 20 Dec 2010 21:23:37 +0000 (22:23 +0100)
If the socket can't be read in time, it raises “socket.timeout”, for
which there is special handling code. Unfortunately the exception block
was in the wrong order and “socket.error” caught it before.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/luxi.py

index 16d969f..78adc9b 100644 (file)
@@ -228,12 +228,12 @@ class Transport:
       while True:
         try:
           data = self.socket.recv(4096)
+        except socket.timeout, err:
+          raise TimeoutError("Receive timeout: %s" % str(err))
         except socket.error, err:
           if err.args and err.args[0] == errno.EAGAIN:
             continue
           raise
-        except socket.timeout, err:
-          raise TimeoutError("Receive timeout: %s" % str(err))
         break
       if not data:
         raise ConnectionClosedError("Connection closed while reading")