def kill_task(task):
status = check_task(task)
if status == 'pending':
return 'cancelled'
# remove job file as well
job_file = os.path.join(os.path.expanduser('~'), '.sos', 'tasks', task + '.sh')
if os.path.isfile(job_file):
try:
os.remove(job_file)
except Exception:
pass
if status != 'running':
return status
# job is running
pulse_file = os.path.join(os.path.expanduser('~'), '.sos', 'tasks', task + '.pulse')
from stat import S_IREAD, S_IRGRP, S_IROTH
os.chmod(pulse_file, S_IREAD|S_IRGRP|S_IROTH)
return 'killed'
评论列表
文章目录