From ca2fcd647ac2f5603d21c19217b8b065d8f968d7 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 19 Aug 2019 13:36:53 -0700 Subject: [PATCH] Add docstring --- .../grpc/_cython/_cygrpc/channel.pyx.pxi | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 53abdc5ec15..c83ff00fedf 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -147,10 +147,27 @@ cdef _cancel( cdef _next_call_event( _ChannelState channel_state, grpc_completion_queue *c_completion_queue, on_success, on_failure, deadline): + """Block on the next event out of the completion queue. + + On success, `on_success` will be invoked with the tag taken from the CQ. + In the case of a failure due to an exception raised in a signal handler, + `on_failure` will be invoked with no arguments. Note that this situation + can only occur on the main thread. + + Args: + channel_state: The state for the channel on which the RPC is running. + c_completion_queue: The CQ which will be polled. + on_success: A callable object to be invoked upon successful receipt of a + tag from the CQ. + on_failure: A callable object to be invoked in case a Python exception is + raised from a signal handler during polling. + deadline: The point after which the RPC will time out. + """ try: tag, event = _latent_event(c_completion_queue, deadline) except: - on_failure() + if on_failure is not None: + on_failure() raise else: with channel_state.condition: