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

[tor-commits] [stem/master] Disabling launch_tor timeout when on windows



commit 688f321287f5e9c53451dd91608dc3aa5088a621
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 20 15:05:10 2012 -0700

    Disabling launch_tor timeout when on windows
    
    On windows the python signal module lacks a SIGALRM attribute, breaking
    launch_tor. Disabling timeouts on windows to avoid this issue - ideally we
    should find an alternative method for timeing out the function on windows but
    that can wait.
    
    Caught by pythonirc101. Issue is discussed on...
    https://trac.torproject.org/projects/tor/ticket/5783
---
 stem/process.py     |    8 ++++++++
 stem/util/system.py |   14 ++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/stem/process.py b/stem/process.py
index a65c124..e004faf 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -11,6 +11,8 @@ import signal
 import tempfile
 import subprocess
 
+import stem.util.system
+
 # number of seconds before we time out our attempt to start a tor instance
 DEFAULT_INIT_TIMEOUT = 90
 
@@ -29,6 +31,9 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
   while. Usually this is done in 50 seconds or so, but occasionally calls seem
   to get stuck, taking well over the default timeout.
   
+  Our timeout argument does not work on Windows...
+  https://trac.torproject.org/projects/tor/ticket/5783
+  
   Arguments:
     tor_cmd (str)              - command for starting tor
     args (list)                - additional arguments for tor
@@ -48,6 +53,9 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
     without success
   """
   
+  if stem.util.system.is_windows():
+    timeout = None
+  
   # double check that we have a torrc to work with
   if not torrc_path in (None, NO_TORRC) and not os.path.exists(torrc_path):
     raise OSError("torrc doesn't exist (%s)" % torrc_path)
diff --git a/stem/util/system.py b/stem/util/system.py
index 6ecc0aa..a4ba186 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -44,13 +44,23 @@ GET_CWD_PWDX             = "pwdx %s"
 GET_CWD_LSOF             = "lsof -a -p %s -d cwd -Fn"
 GET_BSD_JAIL_ID_PS       = "ps -p %s -o jid"
 
+def is_windows():
+  """
+  Checks if we are running on Windows.
+  
+  Returns:
+    bool to indicate if we're on Windows
+  """
+  
+  return platform.system() == "Windows"
+
 def is_bsd():
   """
   Checks if we are within the BSD family of operating systems. This presently
   recognizes Macs, FreeBSD, and OpenBSD but may be expanded later.
   
   Returns:
-    bool to indicate if we're a BSD OS
+    bool to indicate if we're on a BSD OS
   """
   
   return platform.system() in ("Darwin", "FreeBSD", "OpenBSD")
@@ -78,7 +88,7 @@ def is_available(command, cached=True):
     cmd_exists = False
     for path in os.environ["PATH"].split(os.pathsep):
       cmd_path = os.path.join(path, command)
-      if platform.system() == "Windows": cmd_path += ".exe"
+      if is_windows(): cmd_path += ".exe"
       
       if os.path.exists(cmd_path) and os.access(cmd_path, os.X_OK):
         cmd_exists = True



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