Skip to content

Commit

Permalink
fix: clean up HTTP session and pool during tear down phase
Browse files Browse the repository at this point in the history
  • Loading branch information
lidizheng committed Apr 5, 2022
1 parent dc040f5 commit 9bb80e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions google/auth/transport/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions google/auth/transport/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``."""
Expand Down

0 comments on commit 9bb80e6

Please sign in to comment.