diff options
author | Dan Fandrich <danf@mageia.org> | 2013-07-02 21:14:13 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-12-14 17:31:31 +0000 |
commit | 183ff56dde67dae60620c880a4b09c867a0c32cd (patch) | |
tree | 2f3cc73511c12a079e46bf6426f1df68f91f9f3f /MgaRepo | |
parent | a1b2214e865d42b13f83fa6a2c5163de4123ca56 (diff) | |
download | mgarepo-183ff56dde67dae60620c880a4b09c867a0c32cd.tar mgarepo-183ff56dde67dae60620c880a4b09c867a0c32cd.tar.gz mgarepo-183ff56dde67dae60620c880a4b09c867a0c32cd.tar.bz2 mgarepo-183ff56dde67dae60620c880a4b09c867a0c32cd.tar.xz mgarepo-183ff56dde67dae60620c880a4b09c867a0c32cd.zip |
Don't block waiting for stderr when displaying subprocess output (mga#952)
Diffstat (limited to 'MgaRepo')
-rw-r--r-- | MgaRepo/util.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/MgaRepo/util.py b/MgaRepo/util.py index cc08274..62ac32e 100644 --- a/MgaRepo/util.py +++ b/MgaRepo/util.py @@ -7,6 +7,7 @@ import getpass import sys import os import re +import select from cStringIO import StringIO import httplib2 #import commands @@ -35,13 +36,20 @@ def execcmd(*cmd, **kwargs): of = pipe.stdout.fileno() ef = pipe.stderr.fileno() while True: - odata = os.read(of, 8192) - sys.stdout.write(odata) - edata = os.read(ef, 8192) - err.write(edata) - sys.stderr.write(edata) + r,w,x = select.select((of,ef), (), ()) + odata = None + if of in r: + odata = os.read(of, 8192) + sys.stdout.write(odata) + + edata = None + if ef in r: + edata = os.read(ef, 8192) + err.write(edata) + sys.stderr.write(edata) + status = pipe.poll() - if status is not None and not (odata and edata): + if status is not None and odata == "" and edata == "": break output = err.getvalue() else: |