Fix excessive buffering of worker stdout/stderr. (#4094)

* Start workers with 'python -u' to prevent buffering of prints.

* Set sys.stdout and sys.stderr.

* Add comment.
This commit is contained in:
Robert Nishihara
2019-02-19 20:20:47 -08:00
committed by Philipp Moritz
parent 5fe7b1c618
commit e7651b1117
3 changed files with 9 additions and 3 deletions
+6
View File
@@ -1877,6 +1877,12 @@ def connect(info,
# be redirected.
os.dup2(log_stdout_file.fileno(), sys.stdout.fileno())
os.dup2(log_stderr_file.fileno(), sys.stderr.fileno())
# We also manually set sys.stdout and sys.stderr because that seems
# to have an affect on the output buffering. Without doing this,
# stdout and stderr are heavily buffered resulting in seemingly
# lost logging statements.
sys.stdout = log_stdout_file
sys.stderr = log_stderr_file
# This should always be the first message to appear in the worker's
# stdout and stderr log files. The string "Ray worker pid:" is
# parsed in the log monitor process.