summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lee <IanLee1521@gmail.com>2015-01-12 23:45:03 -0800
committerIan Lee <IanLee1521@gmail.com>2015-01-12 23:46:02 -0800
commitcfa24ab02e24914038c55286dbb2f19d1ccf9a31 (patch)
tree70fdae7dbbd9547640fe59243358871a2e2de8b0
parenta94f9256b0a43735207ea67a18a21c67d94f2146 (diff)
downloadpep8-cfa24ab02e24914038c55286dbb2f19d1ccf9a31.tar.gz
Reduce calls to sys.stdout.flush() from 3 to 1; issue #363
-rwxr-xr-xpep8.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/pep8.py b/pep8.py
index 9d3b091..77c5df0 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1681,13 +1681,6 @@ class StandardReport(BaseReport):
'row': self.line_offset + line_number, 'col': offset + 1,
'code': code, 'text': text,
})
- # stdout is block buffered when not stdout.isatty().
- # When using pep8 in multiprocess, line can be broken where
- # buffer boundary since other processes write to same file.
- # So flush() after print() to avoid buffer boundary.
- # Typical buffer size is 8192. line written safely when
- # len(line) < 8192.
- sys.stdout.flush()
if self._show_source:
if line_number > len(self.lines):
line = ''
@@ -1695,10 +1688,16 @@ class StandardReport(BaseReport):
line = self.lines[line_number - 1]
print(line.rstrip())
print(re.sub(r'\S', ' ', line[:offset]) + '^')
- sys.stdout.flush()
if self._show_pep8 and doc:
print(' ' + doc.strip())
- sys.stdout.flush()
+
+ # stdout is block buffered when not stdout.isatty().
+ # line can be broken where buffer boundary since other processes
+ # write to same file.
+ # flush() after print() to avoid buffer boundary.
+ # Typical buffer size is 8192. line written safely when
+ # len(line) < 8192.
+ sys.stdout.flush()
return self.file_errors