diff --git a/google/auth/transport/requests.py b/google/auth/transport/requests.py index a55b5f57b..2805375b8 100644 --- a/google/auth/transport/requests.py +++ b/google/auth/transport/requests.py @@ -149,6 +149,10 @@ def __init__(self, session=None): self.session = session + def __del__(self): + if hasattr(self, 'session') and self.session is not None: + self.session.close() + def __call__( self, url, diff --git a/google/auth/transport/urllib3.py b/google/auth/transport/urllib3.py index ad67327a4..fd14f8873 100644 --- a/google/auth/transport/urllib3.py +++ b/google/auth/transport/urllib3.py @@ -427,6 +427,10 @@ def __exit__(self, exc_type, exc_val, exc_tb): """Proxy to ``self.http``.""" return self.http.__exit__(exc_type, exc_val, exc_tb) + def __del__(self): + if hasattr(self, 'http') and self.http is not None: + self.http.clear() + @property def headers(self): """Proxy to ``self.http``."""