summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-10-02 00:34:02 +0200
committerMichael Schwarz <michi.schwarz@gmail.com>2015-10-02 00:34:02 +0200
commit0a746f9df28a3cdbbac997a636816db2a1ef8eab (patch)
treef8831bc86518293359d1785b671bbefa4fb9863a
parentba3bc0513ebf278d9570d9db5f95b93bad4f0706 (diff)
downloadpogojig-0a746f9df28a3cdbbac997a636816db2a1ef8eab.tar.gz
pogojig-0a746f9df28a3cdbbac997a636816db2a1ef8eab.tar.bz2
pogojig-0a746f9df28a3cdbbac997a636816db2a1ef8eab.zip
Yield to caller of process_context() before wait() is called on the process.
-rw-r--r--support/lib/util.py8
1 files changed, 4 insertions, 4 deletions
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):