Skip to content

Commit

Permalink
Matching process can be interrupted sometimes from jupyter notebook (…
Browse files Browse the repository at this point in the history
…it works when inside the regular search process but not when inside gradient descent, don't know why yet)
  • Loading branch information
Immudzen committed Oct 22, 2019
1 parent 6e9381a commit aa54099
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CADETMatch/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import pandas
import psutil
import signal

class Match:
def __init__(self, json_path):
Expand All @@ -19,6 +20,15 @@ def start_sim(self):
pipe = subprocess.PIPE

proc = subprocess.Popen(command, stdout=pipe, stderr=subprocess.STDOUT, bufsize=1)

def signal_handler(sig, frame):
for child in psutil.Process(proc.pid).children(recursive=True):
child.kill()
proc.kill()
print('Terminating')
sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

for line in iter(proc.stdout.readline, b''):
print(line.decode('utf-8'))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="CADETMatch",
version="0.4.10",
version="0.4.11",
author="William Heymann",
author_email="[email protected]",
description="CADETMatch is a parameter estimation and error modeling library for CADET",
Expand Down

0 comments on commit aa54099

Please sign in to comment.