Skip to content
Snippets Groups Projects
Commit 688f3212 authored by Damian Johnson's avatar Damian Johnson
Browse files

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
parent 4d6c8c89
Branches
Tags
No related merge requests found
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment