Skip to content

Commit

Permalink
Kill subprocesses instead of letting them terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Oct 26, 2023
1 parent 3fbb905 commit 2fb9ffb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion grpc4bmi/bmi_client_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def __init__(self, image: str, work_dir: str, image_port=50051, host=None,
super(BmiClientDocker, self).__init__(BmiClient.create_grpc_channel(port=port, host=host), timeout=timeout)

def __del__(self):
self.container.stop()
if hasattr(self, 'container'):
self.container.stop()

def logs(self) -> str:
"""Returns complete combined stdout and stderr written by the Docker container.
Expand Down
2 changes: 1 addition & 1 deletion grpc4bmi/bmi_client_subproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, module_name, path=None, timeout=None, delay=1):
super(BmiClientSubProcess, self).__init__(BmiClient.create_grpc_channel(port=port, host=host), timeout=timeout)

def __del__(self):
self.pipe.terminate()
self.pipe.kill()
self.pipe.wait(timeout=0.1)

def get_value_ref(self, var_name):
Expand Down

0 comments on commit 2fb9ffb

Please sign in to comment.