Skip to content

Commit cfa24ab

Browse files
committed
Reduce calls to sys.stdout.flush() from 3 to 1; issue #363
1 parent a94f925 commit cfa24ab

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pep8.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,24 +1681,23 @@ def get_file_results(self):
16811681
'row': self.line_offset + line_number, 'col': offset + 1,
16821682
'code': code, 'text': text,
16831683
})
1684-
# stdout is block buffered when not stdout.isatty().
1685-
# When using pep8 in multiprocess, line can be broken where
1686-
# buffer boundary since other processes write to same file.
1687-
# So flush() after print() to avoid buffer boundary.
1688-
# Typical buffer size is 8192. line written safely when
1689-
# len(line) < 8192.
1690-
sys.stdout.flush()
16911684
if self._show_source:
16921685
if line_number > len(self.lines):
16931686
line = ''
16941687
else:
16951688
line = self.lines[line_number - 1]
16961689
print(line.rstrip())
16971690
print(re.sub(r'\S', ' ', line[:offset]) + '^')
1698-
sys.stdout.flush()
16991691
if self._show_pep8 and doc:
17001692
print(' ' + doc.strip())
1701-
sys.stdout.flush()
1693+
1694+
# stdout is block buffered when not stdout.isatty().
1695+
# line can be broken where buffer boundary since other processes
1696+
# write to same file.
1697+
# flush() after print() to avoid buffer boundary.
1698+
# Typical buffer size is 8192. line written safely when
1699+
# len(line) < 8192.
1700+
sys.stdout.flush()
17021701
return self.file_errors
17031702

17041703

0 commit comments

Comments
 (0)