Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #727 #734

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Cyril Roelandt
Eli Collins
Eugene Yunak
Fernando L. Pereira
Florian Schulze
Hazal Ozturk
Henk-Jaap Wagenaar
Ian Stapleton Cordasco
Expand Down
1 change: 1 addition & 0 deletions changelog/727.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The reading of command output sometimes failed with ``IOError: [Errno 0] Error`` on Windows, this was fixed by using a simpler method to update the read buffers. - by @fschulze
8 changes: 4 additions & 4 deletions tox/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
fout.write("actionid: %s\nmsg: %s\ncmdargs: %r\n\n" % (self.id, self.msg, args))
fout.flush()
outpath = py.path.local(fout.name)
fin = outpath.open()
fin = outpath.open('rb')
fin.read() # read the header, so it won't be written to stdout
stdout = fout
elif returnout:
Expand Down Expand Up @@ -163,13 +163,12 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
out = None
last_time = time.time()
while 1:
fin_pos = fin.tell()
# we have to read one byte at a time, otherwise there
# might be no output for a long time with slow tests
data = fin.read(1)
if data:
sys.stdout.write(data)
if '\n' in data or (time.time() - last_time) > 1:
if b'\n' in data or (time.time() - last_time) > 1:
# we flush on newlines or after 1 second to
# provide quick enough feedback to the user
# when printing a dot per test
Expand All @@ -181,7 +180,8 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
break
else:
time.sleep(0.1)
fin.seek(fin_pos)
# the seek updates internal read buffers
fin.seek(0, 1)
fin.close()
else:
out, err = popen.communicate()
Expand Down