perf: 支持终断批量快捷命令执行的任务

This commit is contained in:
wangruidong
2024-03-13 18:18:24 +08:00
committed by Bryan
parent 80035e7cb6
commit dcd7f9f7e6
3 changed files with 49 additions and 3 deletions

View File

@@ -555,10 +555,12 @@ class JobExecution(JMSOrgBaseModel):
ssh_tunnel.local_gateway_clean(runner)
def stop(self):
from ops.signal_handlers import job_execution_stop_pub_sub
with open(os.path.join(self.private_dir, 'local.pid')) as f:
try:
pid = f.read()
os.kill(int(pid), 9)
job_execution_stop_pub_sub.publish(int(pid))
except Exception as e:
print(e)
self.set_error('Job stop by "kill -9 {}"'.format(pid))