Bug with large output on vc commands




I was finding that large projects when doing merges would fail to open in merge.

After a lot of digging, the below patch fixes it. Essentially, subprocess.call blocks when output is directed to a pipe if the output is too large.
Annoyingly subprocess has no 'ignore' flag for output... so the below seems the best from my reading.

Figured given it's small it's fine to send it straight to the list :)

diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index ef556b0..03dced6 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -255,5 +255,10 @@ def popen(cmd, cwd=None):
 
 # Return the return value of a given command
 def call(cmd, cwd=None):
-    return subprocess.call(cmd, cwd=cwd, stdout=subprocess.PIPE,
-                           stderr=subprocess.STDOUT)
+    proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE,
+            stderr=subprocess.STDOUT)
+    while proc.poll() is None:
+        # We don't really care about the output, but we need to read the pipe
+        # or this will block
+        proc.communicate()
+    return proc.returncode

--
Louis



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]