def is_finished_task(self, task_id):
"""Determine if task has finished.
Calling os.waitpid removes finished child process zombies.
"""
pid = self.pid_dict[task_id]
try:
(childpid, status) = os.waitpid(pid, os.WNOHANG)
except OSError as ex:
if ex.errno != errno.ECHILD:
# should not happen
self.log_error("Process hasn't exited with errno.ECHILD: %s" % task_id)
raise
# the process is already gone
return False
if childpid != 0:
prefix = "Task #%s" % task_id
self.log_info(get_process_status(status, prefix))
return True
return False
评论列表
文章目录