Fix the inaccurate cancel injection

pull/22665/head
Lidi Zheng 5 years ago
parent 3e85a129b4
commit 3e187feca0
  1. 5
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi

@ -546,7 +546,10 @@ async def _handle_cancellation_from_core(object rpc_task,
# Awaits cancellation from peer.
await execute_batch(rpc_state, ops, loop)
rpc_state.client_closed = True
if op.cancelled() and not rpc_task.done():
# If 1) received cancel signal; 2) the Task is not finished; 3) the server
# wasn't replying final status. For condition 3, it might cause inaccurate
# log that an RPC is both aborted and cancelled.
if op.cancelled() and not rpc_task.done() and not rpc_state.status_sent:
# Injects `CancelledError` to halt the RPC coroutine
rpc_task.cancel()

Loading…
Cancel
Save