Skip to content

Commit

Permalink
fix test script leaks processes (#6700)
Browse files Browse the repository at this point in the history
  • Loading branch information
EfimovVladimir authored and scottdraves committed Jan 23, 2018
1 parent 41773d8 commit 6c8747d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
def signal_handler(sgnl, frame):
os.killpg(os.getpgid(webcontrol.pid), signal.SIGKILL)
os.killpg(os.getpgid(beakerx.pid), signal.SIGKILL)
os.system("kill -9 `pgrep -f jupyter`")
os.system("kill -9 `pgrep -f webdriver`")
test_console.kill_processes('jupyter')
test_console.kill_processes('webdriver')
test_console.kill_processes('java')
sys.exit(20)
signal.signal(signal.SIGINT, signal_handler)

Expand All @@ -68,6 +69,7 @@ def signal_handler(sgnl, frame):
# Send the signal to all the process groups
os.killpg(os.getpgid(beakerx.pid), signal.SIGKILL)
os.killpg(os.getpgid(webcontrol.pid), signal.SIGKILL)
test_console.kill_processes('java')

if not result:
result = test_console.test_lsmagic()
Expand Down
8 changes: 4 additions & 4 deletions test/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def stop_console(p, pexpect, t):
p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
if p.isalive():
p.terminate()
kill_jupyter()
kill_processes('jupyter')

def test_lsmagic():
result = 0
Expand Down Expand Up @@ -71,10 +71,10 @@ def test_lsmagic():
print("test_lsmagic return code=", result)
return result

def kill_jupyter():
def kill_processes(name):
try:
pidlist = map(int, check_output(['pgrep', '-f', 'jupyter']).split())
pidlist = map(int, check_output(['pgrep', '-f', name]).split())
except CalledProcessError:
pidlist = []
for pid in pidlist:
os.kill(pid, signal.SIGKILL)
os.kill(pid, signal.SIGKILL)

0 comments on commit 6c8747d

Please sign in to comment.