From 081e962469b393f7450815fe534e25d77fd3008c Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 5 Jan 2017 17:26:49 -0800 Subject: [PATCH] utils: If shell.run_parallel is not called before run.shell(), then the lock is not initialized. Thus, we initialize the lock to None and just don't use it because no console output can happen in parallel because we're not running in parallel. --- utils/swift_build_support/swift_build_support/shell.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/shell.py b/utils/swift_build_support/swift_build_support/shell.py index 1ba93f8f9f321..d9331e13d61b6 100644 --- a/utils/swift_build_support/swift_build_support/shell.py +++ b/utils/swift_build_support/swift_build_support/shell.py @@ -175,6 +175,9 @@ def copytree(src, dest, dry_run=None, echo=True): shutil.copytree(src, dest) +# Initialized later +lock = None + def run(*args, **kwargs): repo_path = os.getcwd() echo_output = kwargs.pop('echo', False) @@ -189,7 +192,8 @@ def run(*args, **kwargs): (stdout, stderr) = my_pipe.communicate() ret = my_pipe.wait() - lock.acquire() + if lock: + lock.acquire() if echo_output: print(repo_path) _echo_command(dry_run, *args, env=env) @@ -198,7 +202,8 @@ def run(*args, **kwargs): if stderr: print(stderr, end="") print() - lock.release() + if lock: + lock.release() if ret != 0: eout = Exception()