aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-05-31 05:42:45 +0200
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-05-31 05:42:45 +0200
commitc1b28c4339454e0b895f531432d1ff971222a163 (patch)
tree191617d5743a606f46b498ae71a5c1a3fcec3482 /MgaRepo
parentd09ff463d3461ca55e3c1f8b439d6699ae449763 (diff)
downloadmgarepo-c1b28c4339454e0b895f531432d1ff971222a163.tar
mgarepo-c1b28c4339454e0b895f531432d1ff971222a163.tar.gz
mgarepo-c1b28c4339454e0b895f531432d1ff971222a163.tar.bz2
mgarepo-c1b28c4339454e0b895f531432d1ff971222a163.tar.xz
mgarepo-c1b28c4339454e0b895f531432d1ff971222a163.zip
make sure execcmd() handles large read buffers
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/util.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/MgaRepo/util.py b/MgaRepo/util.py
index ff71ce7..9008a59 100644
--- a/MgaRepo/util.py
+++ b/MgaRepo/util.py
@@ -71,11 +71,17 @@ def execcmd(*cmd, **kwargs):
sys.stdout.write(data)
output = error.getvalue()
else:
- proc.wait()
- if proc.stdout is not None:
- output = proc.stdout.read().decode('utf8')
- if kwargs.get("strip", True):
- output = output.rstrip()
+ # Make sure to avoid buffer getting full.
+ # Otherwise if ie. using proc.wait() both python
+ # and the process will just hang
+ while proc.poll() is None:
+ if proc.stdout is not None:
+ output += proc.stdout.read(8192).decode('utf8')
+ # Make sure that we've emptied the buffer entirely
+ output += proc.stdout.read().decode('utf8')
+
+ if kwargs.get("strip", True):
+ output = output.rstrip()
if (not kwargs.get("noerror")) and proc.returncode != 0:
if kwargs.get("cleanerr"):