def status(self,job_ids):
""" Returns the status of a pid from a local background 'job'
"""
job_ids = set(job_ids)
status_map = dict.fromkeys(job_ids,'Unknown')
for job_id in job_ids:
job_failed_file = os.path.join(self.job_ids.get(job_id, {}).get('cwd'), FAILED_FILE)
if not psutil.pid_exists(int(job_id)):
if os.path.exists(job_failed_file):
status_map[job_id] = JOB_STATUS.FAILED
else:
status_map[job_id] = JOB_STATUS.SUCCEEDED
elif psutil.Process(job_id).status() == psutil.STATUS_ZOMBIE:
if os.path.exists(job_failed_file):
status_map[job_id] = JOB_STATUS.FAILED
else:
status_map[job_id] = JOB_STATUS.SUCCEEDED
else:
status_map[job_id] = JOB_STATUS.RUNNING
return status_map
评论列表
文章目录