Skip to content

Commit 09af02c

Browse files
Maxim ClaeysMaxim Claeys
authored andcommitted
Fix async lock usage
1 parent 0b1f0c0 commit 09af02c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

httpx_auth/oauth2_tokens.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ async def get_token_async(
178178
:raise AuthenticationFailed: in case token cannot be retrieved.
179179
"""
180180
logger.debug(f'Retrieving token with "{key}" key.')
181-
with self.forbid_concurrent_cache_access_async:
181+
async with self.forbid_concurrent_cache_access_async:
182182
self._load_tokens()
183183
if key in self.tokens:
184184
bearer, expiry = self.tokens[key]
@@ -193,7 +193,7 @@ async def get_token_async(
193193

194194
logger.debug("Token cannot be found in cache.")
195195
if on_missing_token is not None:
196-
with self.forbid_concurrent_missing_token_function_call_async:
196+
async with self.forbid_concurrent_missing_token_function_call_async:
197197
new_token = await on_missing_token(**on_missing_token_kwargs)
198198
if len(new_token) == 2: # Bearer token
199199
state, token = new_token
@@ -205,7 +205,7 @@ async def get_token_async(
205205
logger.warning(
206206
f"Using a token received on another key than expected. Expecting {key} but was {state}."
207207
)
208-
with self.forbid_concurrent_cache_access_async:
208+
async with self.forbid_concurrent_cache_access_async:
209209
if state in self.tokens:
210210
bearer, expiry = self.tokens[state]
211211
logger.debug(

0 commit comments

Comments
 (0)