[diffoscope] 05/06: diff: replaces Popen by subprocess.run

Juliana Oliveira jwnx-guest at moszumanska.debian.org
Tue Jan 23 22:03:36 CET 2018


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

jwnx-guest pushed a commit to branch jwnx_parallel_diffoscope
in repository diffoscope.

commit 7a68daed502c57fe63f5c3540654520a9ff0d1e5
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date:   Fri Jan 19 04:39:58 2018 -0200

    diff: replaces Popen by subprocess.run
    
    Popen requires thread/IO micromanaging, and locks some interactions
    with multiprocess lib due to its combined behavior with subprocess.PIPE, being
    unusable with .map function. Subprocess.run simplifies command execution
    by managing threads/IO and is also recommended over Popen since Python
    3.5.
    
    Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
 diffoscope/diff.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/diffoscope/diff.py b/diffoscope/diff.py
index f6d1552..f21aa45 100644
--- a/diffoscope/diff.py
+++ b/diffoscope/diff.py
@@ -72,7 +72,6 @@ class DiffParser(object):
 
         self._action('')
         self._success = True
-        self._output.close()
 
     def read_headers(self, line):
         if not line:
@@ -165,15 +164,15 @@ def run_diff(fifo1, fifo2, end_nl_q1, end_nl_q2):
 
     logger.debug("Running %s", ' '.join(cmd))
 
-    p = subprocess.Popen(
+    p = subprocess.run(
         cmd,
         bufsize=1,
         stdout=subprocess.PIPE,
         stderr=subprocess.STDOUT,
     )
+
     parser = DiffParser(p.stdout, end_nl_q1, end_nl_q2)
     parser.parse()
-    p.wait()
 
     logger.debug(
         "%s: returncode %d, parsed %s",

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


More information about the diffoscope mailing list