-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Moving datastore GAX/gRPC helpers out of _http and into dedicated module. #3036
Conversation
@@ -0,0 +1,197 @@ | |||
# Copyright 2014 Google Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
@contextlib.contextmanager | ||
def _grpc_catch_rendezvous(): | ||
"""Re-map gRPC exceptions that happen in context. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ebeb2e7
to
0109bbd
Compare
@daspecster I folded those changes into the original commit (since they were super tiny) |
SGTM! Thanks! I know they were nitpicky. The rest LGTM but I feel like someone else should take a crack at it. |
from google.cloud import _http as connection_module | ||
from google.cloud.environment_vars import DISABLE_GRPC | ||
from google.cloud.environment_vars import GCD_HOST | ||
from google.cloud import exceptions | ||
from google.cloud.grpc.datastore.v1 import datastore_pb2 as _datastore_pb2 | ||
try: | ||
from grpc import StatusCode | ||
from google.cloud.grpc.datastore.v1 import datastore_pb2_grpc | ||
from google.cloud.datastore._gax import _DatastoreAPIOverGRPC |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
from grpc import StatusCode | ||
from google.cloud.grpc.datastore.v1 import datastore_pb2_grpc | ||
from google.cloud.datastore._gax import _DatastoreAPIOverGRPC | ||
_HAVE_GRPC = True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
yield | ||
except exceptions.GrpcRendezvous as exc: | ||
error_code = exc.code() | ||
error_class = _GRPC_ERROR_MAPPING.get(error_code) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
from grpc import StatusCode | ||
from google.cloud.grpc.datastore.v1 import datastore_pb2_grpc | ||
from google.cloud.datastore._gax import _DatastoreAPIOverGRPC | ||
_HAVE_GRPC = True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Moving datastore GAX/gRPC helpers out of _http and into dedicated module.
This leaves
_http.py
closer to what it should look like, but not all the way there (it is doing some of the transport choosing that should be done inclient.py
)