[Reproducible-commits] [debbindiff] 01/05: Avoid deadlock when calling vimdiff

Jérémy Bobbio lunar at moszumanska.debian.org
Sun Nov 9 11:41:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository debbindiff.

commit ce7ed394e9a0c68099e9f2ab20ec8bf5c6f42713
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Nov 6 19:12:35 2014 +0100

    Avoid deadlock when calling vimdiff
    
    Seems I did not properly read the warning in subprocess documentation:
    “Do not use stdout=PIPE or stderr=PIPE with this function as that can deadlock
    based on the child process output volume”.
    
    And indeed, we had a deadlock on files with very long lines. So let's switch
    to use Popen and communicate().
    
    Closes: #764131, #764420
---
 debbindiff/presenters/html.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/debbindiff/presenters/html.py b/debbindiff/presenters/html.py
index 18d9a0f..9bc1aa7 100644
--- a/debbindiff/presenters/html.py
+++ b/debbindiff/presenters/html.py
@@ -115,17 +115,23 @@ def create_diff(lines1, lines2):
             f.writelines(lines1)
         with open(path2, 'w') as f:
             f.writelines(lines2)
-        subprocess.check_call(
+        p = subprocess.Popen(
             ['vim', '-n', '-N', '-e', '-i', 'NONE', '-u', 'NORC', '-U', 'NORC',
              '-d', path1, path2,
              '-c', 'colorscheme zellner',
              '-c', 'let g:html_number_lines=1',
              '-c', 'let g:html_use_css=1',
+             '-c', 'let g:html_no_progress=1',
              '-c', 'TOhtml',
              '-c', 'w! %s' % (diff_path,),
              '-c', 'qall!',
             ], shell=False, close_fds=True,
             stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        # Consume all output and wait until end of processing
+        _, _ = p.communicate()
+        p.wait()
+        if p.returncode != 0:
+            return 'vim exited with error %d' % p.returncode
         output = open(diff_path).read()
         output = re.search(r'(<table.*</table>)', output,
                            flags=re.MULTILINE | re.DOTALL).group(1)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git



More information about the Reproducible-commits mailing list