Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 78a68b0

Browse files
committedJan 8, 2018
Fix issue tox-dev#727: 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.
1 parent 1f328d1 commit 78a68b0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎changelog/727.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

‎tox/session.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
135135
fout.write("actionid: %s\nmsg: %s\ncmdargs: %r\n\n" % (self.id, self.msg, args))
136136
fout.flush()
137137
outpath = py.path.local(fout.name)
138-
fin = outpath.open()
138+
fin = outpath.open('rb')
139139
fin.read() # read the header, so it won't be written to stdout
140140
stdout = fout
141141
elif returnout:
@@ -163,13 +163,12 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
163163
out = None
164164
last_time = time.time()
165165
while 1:
166-
fin_pos = fin.tell()
167166
# we have to read one byte at a time, otherwise there
168167
# might be no output for a long time with slow tests
169168
data = fin.read(1)
170169
if data:
171170
sys.stdout.write(data)
172-
if '\n' in data or (time.time() - last_time) > 1:
171+
if b'\n' in data or (time.time() - last_time) > 1:
173172
# we flush on newlines or after 1 second to
174173
# provide quick enough feedback to the user
175174
# when printing a dot per test
@@ -181,7 +180,8 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
181180
break
182181
else:
183182
time.sleep(0.1)
184-
fin.seek(fin_pos)
183+
# the seek updates internal read buffers
184+
fin.seek(0, 1)
185185
fin.close()
186186
else:
187187
out, err = popen.communicate()

0 commit comments

Comments
 (0)
Please sign in to comment.