Skip to content

Commit

Permalink
Close auth session (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHayes committed Mar 14, 2022
1 parent 9cbc5aa commit 4a373fa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions gcsfs/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ def maybe_refresh(self):
return # anon
if self.credentials.valid:
return # still good
req = Request(requests.Session())
with self.lock:
if self.credentials.valid:
return # repeat to avoid race (but don't want lock in common case)
logger.debug("GCS refresh")
self.credentials.refresh(req)
self.apply(self.heads)
with requests.Session() as session:
req = Request(session)
with self.lock:
if self.credentials.valid:
return # repeat to avoid race (but don't want lock in common case)
logger.debug("GCS refresh")
self.credentials.refresh(req)
self.apply(self.heads)

def apply(self, out):
"""Insert credential headers in-place to a dictionary"""
Expand Down

0 comments on commit 4a373fa

Please sign in to comment.