Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not handle cancellations gracefully originating from server side #131

Open
AudriusButkevicius opened this issue May 8, 2021 · 1 comment

Comments

@AudriusButkevicius
Copy link

The docs as per https://grpclib.readthedocs.io/en/latest/errors.html#server-side state:

The docs state:

  1. Task running SayHello coroutine gets cancelled and CancelledError is raised inside it
  2. 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
Copy link

Same problem here. These canceled errors (when caused by timeouts) don't even result in grpc's DEADLINE_EXCEEDED status code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants