def __init__(self, task_id, monitor_interval, resource_monitor_interval, max_walltime=None, max_mem=None, max_procs=None):
threading.Thread.__init__(self)
self.task_id = task_id
self.pid = os.getpid()
self.monitor_interval = monitor_interval
self.resource_monitor_interval = max(resource_monitor_interval // monitor_interval, 1)
self.daemon = True
self.max_walltime = max_walltime
if self.max_walltime is not None:
self.max_walltime = expand_time(self.max_walltime)
self.max_mem = max_mem
self.max_procs = max_procs
self.pulse_file = os.path.join(os.path.expanduser('~'), '.sos', 'tasks', task_id + '.pulse')
# remove previous status file, which could be readonly if the job is killed
if os.path.isfile(self.pulse_file):
if not os.access(self.pulse_file, os.W_OK):
os.chmod(self.pulse_file, stat.S_IREAD | stat.S_IWRITE)
os.remove(self.pulse_file)
with open(self.pulse_file, 'w') as pd:
pd.write(f'#task: {task_id}\n')
pd.write(f'#started at {datetime.now().strftime("%A, %d. %B %Y %I:%M%p")}\n#\n')
pd.write('#time\tproc_cpu\tproc_mem\tchildren\tchildren_cpu\tchildren_mem\n')
评论列表
文章目录