Merge ~mwhudson/utah/+git/utah:use-communicate into utah:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Paride Legovini
Approved revision: 181d395a5e93f6dcdb48d49ebfae7e302cc5f96e
Merged at revision: 7b984c27e8652886a5a5874279a5aa830bf9fd78
Proposed branch: ~mwhudson/utah/+git/utah:use-communicate
Merge into: utah:master
Diff against target: 24 lines (+2/-6)
1 file modified
utah/process.py (+2/-6)
Reviewer Review Type Date Requested Status
Paride Legovini Approve
Review via email: mp+369981@code.launchpad.net

Commit message

use Popen.communicate in ProcessRunnner

Probably ProcessRunnner could be done away with entirely but the
existing implementation didn't always collect _all_ of the subprocess'
output, which is a problem if you're trying to interpret it as JSON.

Description of the change

Yes I was very angry when I wrote this, why do you ask?

To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/utah/process.py b/utah/process.py
2index ef56bbf..705b25b 100644
3--- a/utah/process.py
4+++ b/utah/process.py
5@@ -125,11 +125,7 @@ class ProcessRunner(object):
6 logging.debug('Output follows:')
7 p = subprocess.Popen(arglist,
8 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
9- output = []
10- while p.poll() is None:
11- line = p.stdout.readline().strip()
12- logging.debug(line)
13- output.append(line)
14+ stdout, stderr = p.communicate()
15
16 if p.returncode == 0:
17 logging.debug('Return code: {}'.format(p.returncode))
18@@ -137,7 +133,7 @@ class ProcessRunner(object):
19 logging.warning('Command ({}) failed with return code: {}'
20 .format(' '.join(arglist), p.returncode))
21
22- self.output = '\n'.join(output)
23+ self.output = stdout
24 self.returncode = p.returncode
25
26

Subscribers

People subscribed via source and target branches

to all changes: