Skip to content

Commit

Permalink
The one starting server is responsible to make sure it started
Browse files Browse the repository at this point in the history
Refs #16
  • Loading branch information
sverhoeven committed Sep 14, 2018
1 parent 0f2b869 commit 7f78a3c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions grpc4bmi/bmi_client_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import errno

import docker
from wait_for_port import wait_for_port

from grpc4bmi.bmi_grpc_client import BmiClient

Expand Down Expand Up @@ -42,6 +43,7 @@ def __init__(self, image, image_port=50051, host=None, input_dir=None, output_di
user=user,
remove=True,
detach=True)
wait_for_port(port=port, host='localhost' if host is None else host)
super(BmiClientDocker, self).__init__(BmiClient.create_grpc_channel(port=port, host=host))

def __del__(self):
Expand Down
4 changes: 3 additions & 1 deletion grpc4bmi/bmi_client_subproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import subprocess
import time

from wait_for_port import wait_for_port

from grpc4bmi.bmi_grpc_client import BmiClient


Expand All @@ -19,7 +21,7 @@ def __init__(self, module_name):
port_options = ["--port", str(port)]
self.pipe = subprocess.Popen(["run-bmi-server"] + name_options + port_options, env=dict(os.environ),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(1)
wait_for_port(port=port, host='localhost' if host is None else host)
super(BmiClientSubProcess, self).__init__(BmiClient.create_grpc_channel(port=port, host=host))

def __del__(self):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def read(fname):
'futures; python_version == "2.7"',
"docker",
"basic-modeling-interface",
"wait_for_port",
],
extras_require={
'R': ['rpy2'],
Expand Down

0 comments on commit 7f78a3c

Please sign in to comment.