Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: gclient_utils.py

Issue 3140013: Flush more often in gclient's SubprocessCallAndFilter.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
===================================================================
--- gclient_utils.py (revision 56049)
+++ gclient_utils.py (working copy)
@@ -279,6 +279,11 @@
shell=(sys.platform == 'win32'), stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
+ # Do a flush of sys.stdout before we begin reading from the subprocess's
+ # stdout.
+ last_flushed_at = time.time()
+ sys.stdout.flush()
+
# Also, we need to forward stdout to prevent weird re-ordering of output.
# This has to be done on a per byte basis to make sure it is not buffered:
# normally buffering is done for each line, but if svn requests input, no
@@ -295,9 +300,16 @@
sys.stdout.write(in_byte)
if in_byte != '\n':
in_line += in_byte
- if in_byte == '\n' and filter_fn:
- filter_fn(in_line)
+ if in_byte == '\n':
+ if filter_fn:
+ filter_fn(in_line)
in_line = ''
+ # Flush at least 10 seconds between line writes. We wait at least 10
+ # seconds to avoid overloading the reader that called us with output,
+ # which can slow busy readers down.
+ if (time.time() - last_flushed_at) > 10:
+ last_flushed_at = time.time()
+ sys.stdout.flush()
in_byte = kid.stdout.read(1)
rv = kid.wait()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698