Skip to content
Snippets Groups Projects
Commit 2c4a364e authored by Noah Eisen's avatar Noah Eisen Committed by GitHub
Browse files

Merge pull request #9286 from ncteisen/python-stress-wait-for-ready

Modify Python Stress Client to Wait for Ready
parents a3960b98 d70c8bb8
No related branches found
No related tags found
No related merge requests found
...@@ -68,12 +68,8 @@ class BenchmarkClient: ...@@ -68,12 +68,8 @@ class BenchmarkClient:
else: else:
channel = grpc.insecure_channel(server) channel = grpc.insecure_channel(server)
connected_event = threading.Event() # waits for the channel to be ready before we start sending messages
def wait_for_ready(connectivity): grpc.channel_ready_future(channel).result()
if connectivity == grpc.ChannelConnectivity.READY:
connected_event.set()
channel.subscribe(wait_for_ready, try_to_connect=True)
connected_event.wait()
if config.payload_config.WhichOneof('payload') == 'simple_params': if config.payload_config.WhichOneof('payload') == 'simple_params':
self._generic = False self._generic = False
......
...@@ -110,10 +110,13 @@ def _get_channel(target, args): ...@@ -110,10 +110,13 @@ def _get_channel(target, args):
channel_credentials = grpc.ssl_channel_credentials( channel_credentials = grpc.ssl_channel_credentials(
root_certificates=root_certificates) root_certificates=root_certificates)
options = (('grpc.ssl_target_name_override', args.server_host_override,),) options = (('grpc.ssl_target_name_override', args.server_host_override,),)
return grpc.secure_channel( channel = grpc.secure_channel(target, channel_credentials, options=options)
target, channel_credentials, options=options)
else: else:
return grpc.insecure_channel(target) channel = grpc.insecure_channel(target)
# waits for the channel to be ready before we start sending messages
grpc.channel_ready_future(channel).result()
return channel
def run_test(args): def run_test(args):
test_cases = _parse_weighted_test_cases(args.test_cases) test_cases = _parse_weighted_test_cases(args.test_cases)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment