Browse Source

Fix the inaccurate cancel injection

Lidi Zheng 5 năm trước cách đây
mục cha
commit
3e187feca0
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi

+ 4 - 1
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()