Skip to content

Commit bcd5d2b

Browse files
committed
Merge branch 'issue-363' into master
2 parents f7a9648 + 4579585 commit bcd5d2b

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Bug fixes:
5151

5252
* Do not skip physical checks if the newline is escaped. (Issue #319)
5353

54+
* Flush sys.stdout to avoid race conditions with printing. See flake8 bug:
55+
https://gitlab.com/pycqa/flake8/issues/17 for more details. (Issue #363)
56+
5457

5558
1.5.7 (2014-05-29)
5659
------------------

pep8.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,14 @@ def get_file_results(self):
17041704
print(re.sub(r'\S', ' ', line[:offset]) + '^')
17051705
if self._show_pep8 and doc:
17061706
print(' ' + doc.strip())
1707+
1708+
# stdout is block buffered when not stdout.isatty().
1709+
# line can be broken where buffer boundary since other processes
1710+
# write to same file.
1711+
# flush() after print() to avoid buffer boundary.
1712+
# Typical buffer size is 8192. line written safely when
1713+
# len(line) < 8192.
1714+
sys.stdout.flush()
17071715
return self.file_errors
17081716

17091717

testsuite/support.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class PseudoFile(list):
1616
def getvalue(self):
1717
return ''.join(self)
1818

19+
def flush(self):
20+
pass
21+
1922

2023
class TestReport(StandardReport):
2124
"""Collect the results for the tests."""

0 commit comments

Comments
 (0)