Skip to content

Commit

Permalink
fix the issue of prevabs not killed after timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
du135 committed Aug 3, 2021
1 parent f7c1981 commit 7e56f25
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions msgpi/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import signal
import math
import subprocess as sbp
import numpy as np
Expand All @@ -12,15 +13,15 @@ def run(cmd, timeout, scrnout):
# sbp.call(cmd)
proc = sbp.Popen(cmd)
else:
FNULL = open(os.devnull, 'w')
# FNULL = open(os.devnull, 'w')
# sbp.call(cmd, stdout=FNULL, stderr=sbp.STDOUT)
proc = sbp.Popen(cmd, stdout=FNULL, stderr=sbp.STDOUT)
proc = sbp.Popen(cmd, stdout=sbp.DEVNULL, stderr=sbp.STDOUT,preexec_fn=os.setsid)

try:
stdout, stderr = proc.communicate(timeout=timeout)
except sbp.TimeoutExpired as e:
print('TimeoutExpired')
proc.kill()
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
print('Process killed')


Expand Down

0 comments on commit 7e56f25

Please sign in to comment.