Bug 1304282 - Disable output buffering from mozharness spawned processes; r?ted
Without this, process output is buffered by default. This means
timestamps that mozharness prefixes to process output aren't
accurate unless the process is spewing enough output to flush the
output buffer.
Output buffering could lead to bad things. For example, a process
could emit output that would cause mozharness's output monitor to
abort the process. However, if that output is caught in limbo in
the output buffer, mozharness may take several seconds or even
minutes to react.
With this change, the mozharness process receives process output
as soon as that process writes to its standard file descriptors.
Once a newline is seen, mozharness will process it immediately.
Note that this only impacts the case where there is no output
timeout, as the existing code for output timeout uses mozprocess
and I'm pretty sure mozharness doesn't buffer output.
MozReview-Commit-ID: HBkYnfEw7Hb
--- a/testing/mozharness/mozharness/base/script.py
+++ b/testing/mozharness/mozharness/base/script.py
@@ -1360,17 +1360,18 @@ class ScriptMixin(PlatformMixin):
if p.timedOut:
self.log(
'timed out after %s seconds of no output' % output_timeout,
level=error_level
)
returncode = int(p.proc.returncode)
else:
p = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE,
- cwd=cwd, stderr=subprocess.STDOUT, env=env)
+ cwd=cwd, stderr=subprocess.STDOUT, env=env,
+ bufsize=0)
loop = True
while loop:
if p.poll() is not None:
"""Avoid losing the final lines of the log?"""
loop = False
while True:
line = p.stdout.readline()
if not line: