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

Wrap grpc exceptions #72

Closed
takac opened this issue Dec 23, 2016 · 1 comment
Closed

Wrap grpc exceptions #72

takac opened this issue Dec 23, 2016 · 1 comment

Comments

@takac
Copy link
Contributor

takac commented Dec 23, 2016

The client can throw out quite confusing grpc exceptions which could be neatly wrapped.

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  ...
  File "/usr/local/lib/python3.5/site-packages/etcd3/client.py", line 525, in add_member
    self.timeout)
  File "/usr/local/lib/python3.5/site-packages/grpc/_channel.py", line 481, in __call__
    return _end_unary_response_blocking(state, False, deadline)
  File "/usr/local/lib/python3.5/site-packages/grpc/_channel.py", line 432, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)

Deadline exceeded is a non critical error I would like to catch:

for i in range(4):
    try:
        etcd.add_member(["http://172.1.1.1:2380"])
        return True   
    except DeadlineExceeded:
        print("hit deadline")
     return False

Another obvious one I have seen: StatusUnavailable

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/etcd3/client.py", line 564, in members
    self.timeout)
  File "/usr/local/lib/python3.5/site-packages/grpc/_channel.py", line 481, in __call__
    return _end_unary_response_blocking(state, False, deadline)
  File "/usr/local/lib/python3.5/site-packages/grpc/_channel.py", line 432, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, )>
@kragniz
Copy link
Owner

kragniz commented Jan 4, 2017

Should be fixed with #63

@kragniz kragniz closed this as completed Jan 4, 2017
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