Skip to content

Commit

Permalink
Dont track ports used by client
Browse files Browse the repository at this point in the history
The are not released and the client should not care if the same port is used multiple times.

Refs #63
  • Loading branch information
sverhoeven committed Mar 13, 2020
1 parent 1fdd8c6 commit 659304b
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions grpc4bmi/bmi_grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class BmiClient(Bmi):
>>> print(mymodel.get_component_name())
Hello world
"""
occupied_ports = set()

def __init__(self, channel=None, timeout=None, stub=None):
if stub is None:
Expand All @@ -76,11 +75,7 @@ def create_grpc_channel(port=0, host=None):
if h is None:
h = "localhost"
if p == 0:
p = os.environ.get("BMI_PORT", 55555)
elif p in BmiClient.occupied_ports:
log.error("Attempt to create grpc channel on occupied port %d" % p)
return None
BmiClient.occupied_ports.add(p)
p = os.environ.get("BMI_PORT", 50051)
return grpc.insecure_channel(':'.join([h, str(p)]))

@staticmethod
Expand Down

0 comments on commit 659304b

Please sign in to comment.