[Async ExecuteBatchError Issue] Log instead of raise ExecuteBatchError in Aysncio server (#32551)

### Description
When invoking a RPC, sometimes operations in core will fail which result
in an `ExecuteBatchError`, currently we [simply raise this
error](https://github.com/grpc/grpc/blob/master/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi#L705),
and left this Exception unhandled in event loop with error message `Task
exception was never retrieved`.

### Changes included
This PR changes the behavior to log the `ExecuteBatchError` instead of
raising it.

This shouldn't change existing behavior because even without this
change, the exception will simply left on event loop.

### Testing

Tested by manually `set_expection` in [this
future](https://github.com/grpc/grpc/blob/master/src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi#L84),
verified that error was logged correctly and no exception was left in
event loop, sample log:

```
ERROR:grpc._cython.cygrpc:ExecuteBatchError raised in core by servicer method [/grpc.testing.TestService/UnaryCall]
Traceback (most recent call last):
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi", line 682, in _cython.cygrpc._handle_exceptions
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi", line 802, in _handle_rpc
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi", line 547, in _handle_unary_unary_rpc
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi", line 452, in _finish_handler_with_unary_response
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi", line 106, in execute_wrong_batch
_cython.cygrpc.ExecuteBatchError: Failed "execute_batch_including_SendInitialMetadataOperation": (<_cython.cygrpc.SendInitialMetadataOperation object at 0x7fa86d936ca0>, <_cython.cygrpc.SendMessageOperation object at 0x7fa86cf48cb0>, <_cython.cygrpc.SendStatusFromServerOperation object at 0x7fa86cf4c110>)
```
pull/32814/head
Xuan Wang 2 years ago committed by GitHub
parent bdd1ac4d1d
commit 5452017fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi

@ -702,7 +702,9 @@ async def _handle_exceptions(RPCState rpc_state, object rpc_coro, object loop):
if rpc_state.client_closed:
return
else:
raise
_LOGGER.exception('ExecuteBatchError raised in core by servicer method [%s]' % (
_decode(rpc_state.method())))
return
except Exception as e:
_LOGGER.exception('Unexpected [%s] raised by servicer method [%s]' % (
type(e).__name__,

Loading…
Cancel
Save