In addition, it seems like the callback functionality should be able handle
this through something like this ...
Server pseudo-code:
def Server(self, request_iterator, context):
context.add_callback(context.cancel())
for request in request_iterator:
pass
for _ in range(10):
time.sleep(1)
print(context.is_active())
print('still running!')
return test_pb2.Response()
... however, this immediately cancels the RPC, which seems to disagree with
the intended behavior described in the
documentation:
https://grpc.io/grpc/python/grpc.html#grpc.RpcContext.add_callback
On Tuesday, March 19, 2019 at 9:48:53 AM UTC-7, [email protected] wrote:
>
> I want to verify some behavior in the Python code -- are timeouts only
> respected while receiving requests and not after requests have been
> received (but RPC is not finished)? Here's an example that uses a
> client-streaming RPC:
>
> Server pseudo-code:
>
> def Server(self, request_iterator, context):
> for request in request_iterator:
> pass
>
> for _ in range(10):
> time.sleep(1)
>
> print(context.is_active())
> print('still running!')
> return test_pb2.Response()
>
>
> Client pseudo-code:
>
> def yielder():
> for _ in range(20):
> yield test_pb2.Request()
>
> stub = test_pb2_grpc.TestStub(channel)
> response = stub.Server(yielder(), timeout=5)
> print(response)
>
>
> What happens is that the server will receive all the requests streams and
> while performing an operation, the timeout will pass and context will be
> inactive -- however, the RPC never aborts (i.e. the server will print
> 'still running!'). Is this intended behavior? I would expect that the
> server to stop processing after the timeout has elapsed.
>
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/a9d19d24-75d0-459f-ac51-c15a4d02422e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.