commit a564ae2a6c24aebb822e777e7dea8bda3cffcf68 Author: Damian Johnson atagar@torproject.org Date: Thu Mar 7 09:33:37 2013 -0800
stem.process.launch_tor() doesn't work without stdout logging
The launch_tor() function uses tor's stdout logs to figure out when it has finished bootstrapping. This, of course, doesn't work if tor isn't logging to stdout...
https://trac.torproject.org/7677
Changing launch_tor_with_config() to slip in a 'Log NOTICE stdout' option so it always works, and adding a note to launch_tor() warning users of the requirement. --- stem/process.py | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/stem/process.py b/stem/process.py index e21b077..0764d7f 100644 --- a/stem/process.py +++ b/stem/process.py @@ -43,6 +43,10 @@ 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.
+ **To work to must log at NOTICE runlevel to stdout.** It does this by + default, but if you have a 'Log' entry in your torrc then you'll also need + 'Log NOTICE stdout'. + Note: The timeout argument does not work on Windows (`ticket https://trac.torproject.org/5783`_)
@@ -221,6 +225,25 @@ def launch_tor_with_config(config, tor_cmd = "tor", completion_percent = 100, in timeout without success """
+ # we need to be sure that we're logging to stdout to figure out when we're + # done bootstrapping + + if 'Log' in config: + stdout_options = ['DEBUG stdout', 'INFO stdout', 'NOTICE stdout'] + + if isinstance(config['Log'], str): + config['Log'] = [config['Log']] + + has_stdout = False + + for log_config in config['Log']: + if log_config in stdout_options: + has_stdout = True + break + + if not has_stdout: + config['Log'].append('NOTICE stdout') + torrc_path = tempfile.mkstemp(prefix = "torrc-", text = True)[1]
try:
tor-commits@lists.torproject.org