mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 19:41:45 +08:00
Fix log files being opened as unicode files (#5545)
This commit is contained in:
committed by
Robert Nishihara
parent
52a6a1b9f7
commit
ddfababb82
@@ -144,7 +144,7 @@ class LogMonitor(object):
|
||||
# file.
|
||||
if file_size > file_info.size_when_last_opened:
|
||||
try:
|
||||
f = open(file_info.filename, "r")
|
||||
f = open(file_info.filename, "rb")
|
||||
except (IOError, OSError) as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
logger.warning("Warning: The file {} was not "
|
||||
@@ -179,6 +179,10 @@ class LogMonitor(object):
|
||||
for _ in range(max_num_lines_to_read):
|
||||
try:
|
||||
next_line = file_info.file_handle.readline()
|
||||
# Replace any characters not in UTF-8 with
|
||||
# a replacement character, see
|
||||
# https://stackoverflow.com/a/38565489/10891801
|
||||
next_line = next_line.decode("utf-8", "replace")
|
||||
if next_line == "":
|
||||
break
|
||||
if next_line[-1] == "\n":
|
||||
|
||||
Reference in New Issue
Block a user