Does not handle cancellations gracefully originating from server side
Opened this issue · 1 comments
AudriusButkevicius commented
The docs as per https://grpclib.readthedocs.io/en/latest/errors.html#server-side state:
The docs state:
- Task running SayHello coroutine gets cancelled and CancelledError is raised inside it
- When SayHello coroutine finishes, grpclib server internally re-raises CancelledError as TimeoutError or StreamTerminatedError to explain why request was cancelled
However, I still end up with the following in my application logs:
Application error
Traceback (most recent call last):
File "/home/audriusb/code/python_prod/.venv/lib/python3.7/site-packages/grpclib/server.py", line 440, in request_handler
await method_func(stream)
File "/home/audriusb/code/python_prod/src/framework/base.py", line 122, in GetValues
raise e
File "/home/audriusb/code/python_prod/src/framework/base.py", line 114, in GetValues
raise e
File "/home/audriusb/code/python_prod/src/framework/base.py", line 97, in GetValues
async for m in impl:
File "/home/audriusb/code/python_prod/src/framework/base.py", line 172, in calculate
async for a in aiter:
File "/home/audriusb/code/python_prod/src/handler.py", line 21, in impl
await asyncio.sleep(90000)
File "/home/audriusb/.pyenv/versions/3.7.9/lib/python3.7/asyncio/tasks.py", line 595, in sleep
return await future
concurrent.futures._base.CancelledError
I don't see any handling of CancelledError around the code that invokes the handler: https://github.com/vmagamedov/grpclib/blob/master/grpclib/server.py#L440
I see there is cancel handling in the wrapper object, but I think that is mostly for client cancelling the stream, not server calls being cancelled because it's shutting down?
alitoufighi commented
Same problem here. These canceled errors (when caused by timeouts) don't even result in grpc's DEADLINE_EXCEEDED
status code.