# Buggy code
def close_all_files(self):
    """Close all open files (so that we can open more)."""
    while len(self.open_file_infos) > 0:
        file_info = self.open_file_infos.pop(0)
        file_info.file_handle.close()
        file_info.file_handle = None
        try:
            # Test if the worker process that generated the log file
            # is still alive. Only applies to worker processes.
            if (
                file_info.worker_pid != "raylet"
                and file_info.worker_pid != "gcs_server"
            ):
                os.kill(file_info.worker_pid, 0)
        except OSError:
            # The process is not alive any more, so move the log file
            # out of the log directory so glob.glob will not be slowed
            # by it.
            target = os.path.join(
                self.logs_dir, "old", os.path.basename(file_info.filename)
            )
            try:
                shutil.move(file_info.filename, target)
            except (IOError, OSError) as e:
                if e.errno == errno.ENOENT:
                    logger.warning(
                        f"Warning: The file {file_info.filename} was not found."
                    )
                else:
                    raise e
        else:
            self.closed_file_infos.append(file_info)
    self.can_open_more_files = True


# Traceback (TypeError)
2020-12-02 07:26:37,751	WARNING worker.py:1011 -- The log monitor on node ip-172-31-18-179 failed with the following error:
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/ray/log_monitor.py", line 354, in <module>
log_monitor.run()
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/ray/log_monitor.py", line 275, in run
self.open_closed_files()
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/ray/log_monitor.py", line 164, in open_closed_files
self.close_all_files()
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/ray/log_monitor.py", line 102, in close_all_files
os.kill(file_info.worker_pid, 0)
TypeError: an integer is required (got type str)

# Fixed code
def close_all_files(self):
    """Close all open files (so that we can open more)."""
    while len(self.open_file_infos) > 0:
        file_info = self.open_file_infos.pop(0)
        file_info.file_handle.close()
        file_info.file_handle = None
        try:
            # Test if the worker process that generated the log file
            # is still alive. Only applies to worker processes.
            if (
                file_info.worker_pid != "raylet"
                and file_info.worker_pid != "gcs_server"
                and file_info.worker_pid != "autoscaler"
            ):
                os.kill(file_info.worker_pid, 0)
        except OSError:
            # The process is not alive any more, so move the log file
            # out of the log directory so glob.glob will not be slowed
            # by it.
            target = os.path.join(
                self.logs_dir, "old", os.path.basename(file_info.filename)
            )
            try:
                shutil.move(file_info.filename, target)
            except (IOError, OSError) as e:
                if e.errno == errno.ENOENT:
                    logger.warning(
                        f"Warning: The file {file_info.filename} was not found."
                    )
                else:
                    raise e
        else:
            self.closed_file_infos.append(file_info)
    self.can_open_more_files = True