[tor-commits] [stem/master] Single retry for socket connection
atagar at torproject.org
atagar at torproject.org
Tue May 29 01:08:25 UTC 2012
commit 72aed261dceb560d05563fab1af4e6f549e2bdfd
Author: Damian Johnson <atagar at torproject.org>
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):
"""
More information about the tor-commits
mailing list