Revert "Merge pull request #22373 from gnossen/creds_threads_and_breads"

This reverts commit 61a0212539, reversing
changes made to 19d8e2c551.
pull/22385/head
Richard Belleville 5 years ago
parent f2751504c1
commit 24e03778ea
  1. 11
      src/python/grpcio/grpc/_auth.py

@ -40,10 +40,9 @@ def _create_get_token_callback(callback):
class GoogleCallCredentials(grpc.AuthMetadataPlugin):
"""Metadata wrapper for GoogleCredentials from the oauth2client library."""
_THREAD_POOL = futures.ThreadPoolExecutor()
def __init__(self, credentials):
self._credentials = credentials
self._pool = futures.ThreadPoolExecutor(max_workers=1)
# Hack to determine if these are JWT creds and we need to pass
# additional_claims when getting a token
@ -53,14 +52,16 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin):
def __call__(self, context, callback):
# MetadataPlugins cannot block (see grpc.beta.interfaces.py)
if self._is_jwt:
future = self._THREAD_POOL.submit(
future = self._pool.submit(
self._credentials.get_access_token,
additional_claims={'aud': context.service_url})
else:
future = self._THREAD_POOL.submit(
self._credentials.get_access_token)
future = self._pool.submit(self._credentials.get_access_token)
future.add_done_callback(_create_get_token_callback(callback))
def __del__(self):
self._pool.shutdown(wait=False)
class AccessTokenAuthMetadataPlugin(grpc.AuthMetadataPlugin):
"""Metadata wrapper for raw access token credentials."""

Loading…
Cancel
Save