aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/python/grpcio_tests/tests/interop/methods.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/python/grpcio_tests/tests/interop/methods.py b/src/python/grpcio_tests/tests/interop/methods.py
index 7edd75c56c..c4a0c08430 100644
--- a/src/python/grpcio_tests/tests/interop/methods.py
+++ b/src/python/grpcio_tests/tests/interop/methods.py
@@ -159,16 +159,6 @@ def _server_streaming(stub):
raise ValueError(
'response body of invalid size %d!' % len(response.payload.body))
-def _cancel_after_begin(stub):
- sizes = (27182, 8, 1828, 45904,)
- payloads = (messages_pb2.Payload(body=b'\x00' * size) for size in sizes)
- requests = (messages_pb2.StreamingInputCallRequest(payload=payload)
- for payload in payloads)
- response_future = stub.StreamingInputCall.future(requests)
- response_future.cancel()
- if not response_future.cancelled():
- raise ValueError('expected call to be cancelled')
-
class _Pipe(object):
@@ -232,6 +222,16 @@ def _ping_pong(stub):
'response body of invalid size %d!' % len(response.payload.body))
+def _cancel_after_begin(stub):
+ with _Pipe() as pipe:
+ response_future = stub.StreamingInputCall.future(pipe)
+ response_future.cancel()
+ if not response_future.cancelled():
+ raise ValueError('expected cancelled method to return True')
+ if response_future.code() is not grpc.StatusCode.CANCELLED:
+ raise ValueError('expected status code CANCELLED')
+
+
def _cancel_after_first_response(stub):
request_response_sizes = (31415, 9, 2653, 58979,)
request_payload_sizes = (27182, 8, 1828, 45904,)