[tor-commits] [chutney/master] wait_for_bootstrap: Make time limit configurable.

teor at torproject.org teor at torproject.org
Wed Mar 13 03:16:56 UTC 2019


commit 9934f8b6d26eee77cc4a6ababca794717c2031b4
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Mar 12 09:44:38 2019 -0400

    wait_for_bootstrap: Make time limit configurable.
    
    (Also define a utility function to extract an environment variable
    as an integer, since we seem to do this a lot, and we are sometimes
    sloppy about it.)
---
 lib/chutney/TorNet.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 4939840..5722402 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -37,6 +37,22 @@ torrc_option_warn_count =  0
 # Get verbose tracebacks, so we can diagnose better.
 cgitb.enable(format="plain")
 
+def getenv_int(envvar, default):
+    """
+       Return the value of the environment variable 'envar' as an integer,
+       or 'default' if no such variable exists.
+
+       Raise ValueError if the environment variable is set, but not to
+       an integer.
+    """
+    # TODO: Use this function in more places.
+    strval = os.environ.get(envvar)
+    if strval is None:
+        return default
+    try:
+        return int(strval)
+    except ValueError:
+        raise ValueError("Invalid value for environment variable %s: expected an integer, but got %r"%(envvar,strval))
 
 def mkdir_p(d, mode=448):
     """Create directory 'd' and all of its parents as needed.  Unlike
@@ -1151,7 +1167,7 @@ class Network(object):
 
     def wait_for_bootstrap(self):
         print("Waiting for nodes to bootstrap...")
-        limit = 20 #bootstrap time
+        limit = getenv_int("CHUTNEY_START_TIME", 20)
         delay = 0.5
         controllers = [n.getController() for n in self._nodes]
         elapsed = 0.0





More information about the tor-commits mailing list