def check_log_files_and_publish_updates(self):
        """Get any changes to the log files and push updates to Redis.

        Returns:
            True if anything was published and false otherwise.
        """
        anything_published = False
        for file_info in self.open_file_infos:
            assert not file_info.file_handle.closed

            lines_to_publish = []
            max_num_lines_to_read = 100
            for _ in range(max_num_lines_to_read):
                next_line = file_info.file_handle.readline()
                if next_line == "":
                    break
                if next_line[-1] == "\n":
                    next_line = next_line[:-1]
                lines_to_publish.append(next_line)

            # Publish the lines if this is a worker process.
            filename = file_info.filename.split("/")[-1]
            is_worker = (filename.startswith("worker")
                         and (filename.endswith("out")
                              or filename.endswith("err")))

            if is_worker and file_info.file_position == 0:
                if (len(lines_to_publish) > 0 and
                        lines_to_publish[0].startswith("Ray worker pid: ")):
                    file_info.worker_pid = int(
                        lines_to_publish[0].split(" ")[-1])
                    lines_to_publish = lines_to_publish[1:]

            # Record the current position in the file.
            file_info.file_position = file_info.file_handle.tell()

            if len(lines_to_publish) > 0 and is_worker:
                self.redis_client.publish(
                    ray.gcs_utils.LOG_FILE_CHANNEL,
                    json.dumps({
                        "ip": self.ip,
                        "pid": file_info.worker_pid,
                        "lines": lines_to_publish
                    }))
                anything_published = True

        return anything_published
def check_log_files_and_publish_updates ( self ) : anything_published = False for file_info in self . open_file_infos : assert not file_info . file_handle . closed lines_to_publish = [ ] max_num_lines_to_read = 100 for _ in range ( max_num_lines_to_read ) : next_line = file_info . file_handle . readline ( ) if next_line == "" : break if next_line [ - 1 ] == "\n" : next_line = next_line [ : - 1 ] lines_to_publish . append ( next_line ) filename = file_info . filename . split ( "/" ) [ - 1 ] is_worker = ( filename . startswith ( "worker" ) and ( filename . endswith ( "out" ) or filename . endswith ( "err" ) ) ) if is_worker and file_info . file_position == 0 : if ( len ( lines_to_publish ) > 0 and lines_to_publish [ 0 ] . startswith ( "Ray worker pid: " ) ) : file_info . worker_pid = int ( lines_to_publish [ 0 ] . split ( " " ) [ - 1 ] ) lines_to_publish = lines_to_publish [ 1 : ] file_info . file_position = file_info . file_handle . tell ( ) if len ( lines_to_publish ) > 0 and is_worker : self . redis_client . publish ( ray . gcs_utils . LOG_FILE_CHANNEL , json . dumps ( { "ip" : self . ip , "pid" : file_info . worker_pid , "lines" : lines_to_publish } ) ) anything_published = True return anything_published
Get any changes to the log files and push updates to Redis.

        Returns:
            True if anything was published and false otherwise.