From 0a746f9df28a3cdbbac997a636816db2a1ef8eab Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Fri, 2 Oct 2015 00:34:02 +0200 Subject: Yield to caller of process_context() before wait() is called on the process. --- support/lib/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'support') diff --git a/support/lib/util.py b/support/lib/util.py index d88f9f6..8b38bc2 100644 --- a/support/lib/util.py +++ b/support/lib/util.py @@ -73,7 +73,6 @@ def command_context(args, remove_env = [], set_env = { }, working_dir = None, us try: process = subprocess.Popen(args, env = env, cwd = working_dir, stderr = stderr) - process.wait() except OSError as e: raise UserError('Error running {}: {}', args[0], e) @@ -88,15 +87,16 @@ def command_context(args, remove_env = [], set_env = { }, working_dir = None, us raise finally: - process.wait() + # Use communicate so that we won't deadlock if the process generates some unread output. + process.communicate() if process.returncode: raise UserError('Command failed: {}', ' '.join(args)) def command(args, remove_env = [], set_env = { }, working_dir = None): - with command_context(args, remove_env, set_env, working_dir) as process: - process.wait() + with command_context(args, remove_env, set_env, working_dir): + pass def bash_escape_string(string): -- cgit