|
|
|
@ -34,6 +34,8 @@ class GenericStub(object): |
|
|
|
|
def __init__(self, channel): |
|
|
|
|
self.UnaryCall = channel.unary_unary( |
|
|
|
|
'/grpc.testing.BenchmarkService/UnaryCall') |
|
|
|
|
self.StreamingFromServer = channel.unary_stream( |
|
|
|
|
'/grpc.testing.BenchmarkService/StreamingFromServer') |
|
|
|
|
self.StreamingCall = channel.stream_stream( |
|
|
|
|
'/grpc.testing.BenchmarkService/StreamingCall') |
|
|
|
|
|
|
|
|
@ -200,3 +202,31 @@ class StreamingSyncBenchmarkClient(BenchmarkClient): |
|
|
|
|
stream.stop() |
|
|
|
|
self._pool.shutdown(wait=True) |
|
|
|
|
self._stub = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServerStreamingSyncBenchmarkClient(BenchmarkClient): |
|
|
|
|
|
|
|
|
|
def __init__(self, server, config, hist): |
|
|
|
|
super(ServerStreamingSyncBenchmarkClient, |
|
|
|
|
self).__init__(server, config, hist) |
|
|
|
|
self._pool = futures.ThreadPoolExecutor( |
|
|
|
|
max_workers=config.outstanding_rpcs_per_channel) |
|
|
|
|
self._rpcs = [] |
|
|
|
|
|
|
|
|
|
def send_request(self): |
|
|
|
|
self._pool.submit(self._one_stream_streaming_rpc) |
|
|
|
|
|
|
|
|
|
def _one_stream_streaming_rpc(self): |
|
|
|
|
response_stream = self._stub.StreamingFromServer( |
|
|
|
|
self._request, _TIMEOUT) |
|
|
|
|
self._rpcs.append(response_stream) |
|
|
|
|
start_time = time.time() |
|
|
|
|
for _ in response_stream: |
|
|
|
|
self._handle_response(self, time.time() - start_time) |
|
|
|
|
start_time = time.time() |
|
|
|
|
|
|
|
|
|
def stop(self): |
|
|
|
|
for call in self._rpcs: |
|
|
|
|
call.cancel() |
|
|
|
|
self._pool.shutdown(wait=False) |
|
|
|
|
self._stub = None |
|
|
|
|