Skip to content

Commit d41e502

Browse files
committed
fix: stop process bug
1 parent b269279 commit d41e502

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

task/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __str__(self):
9999
return self.task.name + '-' + str(self.index)
100100

101101
def kill(self):
102-
os.kill(self.pid, signal.SIGKILL)
102+
os.kill(self.pid, signal.SIGINT)
103103

104104
def delete_log_file(self):
105105
if os.path.isfile(self.log_file_path):

task/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
def generate_ssh_cmd(host, user, exec_cmd, private_key_path=None):
1616
exec_cmd = exec_cmd.replace('$', '\\$')
1717
if private_key_path is None:
18-
cmd = "ssh -o StrictHostKeyChecking=no {}@{} \"{}\"".format(user, host, exec_cmd)
18+
cmd = "ssh -tt -o StrictHostKeyChecking=no {}@{} \"{}\"".format(user, host, exec_cmd)
1919
else:
20-
cmd = "ssh -o StrictHostKeyChecking=no -i {} {}@{} \"{}\"".format(private_key_path, user, host, exec_cmd)
20+
cmd = "ssh -tt -o StrictHostKeyChecking=no -i {} {}@{} \"{}\"".format(private_key_path, user, host, exec_cmd)
2121
return cmd
2222

2323

@@ -28,7 +28,7 @@ def __init__(self, user, host, cmd, workspace="~", private_key_path=None, output
2828
if output_file is not None:
2929
self.output_file = output_file
3030
with open(self.output_file, "wb") as out:
31-
self.proc = subprocess.Popen(self.cmd, shell=True, stdout=out, stderr=out, bufsize=1)
31+
self.proc = subprocess.Popen(self.cmd, shell=True, stdin=subprocess.PIPE, stdout=out, stderr=out, bufsize=1)
3232
else:
3333
self.proc = subprocess.Popen(self.cmd, shell=True)
3434

@@ -37,7 +37,8 @@ def pid(self):
3737

3838
def kill(self):
3939
# os.killpg(os.getpgid(self.proc.pid), signal.SIGKILL)
40-
os.kill(self.proc.pid, signal.SIGKILL)
40+
# os.kill(self.proc.pid, signal.SIGKILL)
41+
self.proc.send_signal(signal.SIGINT)
4142

4243
def get_return_code(self):
4344
self.proc.wait()

0 commit comments

Comments
 (0)