summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-12-01 15:23:34 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-12-01 15:23:34 +0000
commitd37acb166d2416f5ae142a95655666fb19966cf7 (patch)
tree5c2834b4a5b24ba5e20dedb5ef25ed5162a048f9
parente5070dbe6ae22d7d81d89c57700992e9a1e15d19 (diff)
downloadimport-d37acb166d2416f5ae142a95655666fb19966cf7.tar.gz
Let Popen do the multiplexing
-rwxr-xr-xexts/pip.find_deps27
1 files changed, 6 insertions, 21 deletions
diff --git a/exts/pip.find_deps b/exts/pip.find_deps
index d788143..30ef507 100755
--- a/exts/pip.find_deps
+++ b/exts/pip.find_deps
@@ -250,34 +250,19 @@ def find_runtime_deps(source, name, version=None):
p = subprocess.Popen(['pip', 'install', '.',
'--list-dependencies=%s' % tmppath], cwd=source,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
stdin=subprocess.PIPE)
# We close stdin on parent side to prevent the child from blocking
# if it reads on stdin
p.stdin.close()
- poll = select.poll()
+ while True:
+ line = p.stdout.readline()
+ if line == '':
+ break
- logging.debug('p.stdout: %s' % p.stdout)
- logging.debug('p.stderr: %s' % p.stderr)
-
- fdmap = {p.stdout.fileno(): p.stdout, p.stderr.fileno(): p.stderr}
- poll.register(p.stdout)
- poll.register(p.stderr)
-
- # Multiplex stdout and stderr
- # TODO: replace by setting stderr=stdout
- while fdmap != {}:
- fds = poll.poll()
-
- for (fd, _) in fds:
- line = fdmap[fd].readline()
- if line == '':
- poll.unregister(fd)
- del fdmap[fd]
- else:
- logging.debug('%s' % line.rstrip())
+ logging.debug(line.rstrip())
p.wait() # even with eof on both streams, we still wait