[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Single retry for socket connection



commit 72aed261dceb560d05563fab1af4e6f549e2bdfd
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon May 28 15:23:52 2012 -0700

    Single retry for socket connection
    
    I just had integ tests fail due to an interrupt while trying to connect to the
    tor control socket. This is the first time that I've seen it, so this isn't
    much of a concern, but connecting to a socket is idempotent so we can do with
    retrying it once if we fail.
---
 stem/socket.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/stem/socket.py b/stem/socket.py
index 6f0bfda..5abe902 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -206,7 +206,15 @@ class ControlSocket:
         self._socket_file = self._socket.makefile()
         self._is_alive = True
         
-        self._connect()
+        # It's possable for this to have a transient failure...
+        # SocketError: [Errno 4] Interrupted system call
+        #
+        # It's safe to retry, so give it another try if it fails.
+        
+        try:
+          self._connect()
+        except SocketError:
+          self._connect() # single retry
   
   def close(self):
     """



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits