Skip to content

Commit

Permalink
Merge 3b296ff into 36120f2
Browse files Browse the repository at this point in the history
  • Loading branch information
Byvire committed Apr 13, 2018
2 parents 36120f2 + 3b296ff commit 93e65c1
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions pygraphviz/agraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,28 +1304,28 @@ def _run_prog(self, prog='nop', args=''):
runprog = r'"%s"' % self._get_prog(prog)
cmd = ' '.join([runprog, args])
dotargs = shlex.split(cmd)
p = subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()

self.write(child_stdin)
child_stdin.close()

for t in threads:
t.join()
with subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False) as p:
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()

self.write(child_stdin)
child_stdin.close()

for t in threads:
t.join()

if not data:
raise IOError(b"".join(errors).decode(self.encoding))
Expand Down

0 comments on commit 93e65c1

Please sign in to comment.