@@ -3771,20 +3771,12 @@ async def __aenter__(self):
37713771 async def __aexit__ (self , * _exc : object ) -> None :
37723772 self ._inner .release ()
37733773
3774- async def acquire (self ) -> None :
3775- await self ._inner .acquire ()
3776-
3777- def release (self ) -> None :
3778- self ._inner .release ()
3779-
3780- def locked (self ) -> bool :
3781- return self ._inner .locked ()
3782-
37833774 lock = HoldableLock ()
37843775 # anyio.Lock.acquire is read-only, so the stand-in cannot be a subclass patch.
37853776 # The field is typed as anyio.Lock; setattr keeps the assignment off the checker.
37863777 object .__setattr__ (oauth_provider .context , "refresh_lock" , lock )
3787- await lock .acquire ()
3778+ # First entry is before the waiter is armed, so both arms of `__aenter__` run.
3779+ await lock .__aenter__ ()
37883780 lock .arm = True
37893781 sent : list [httpx2 .Request ] = []
37903782
@@ -3797,16 +3789,12 @@ async def drive() -> None:
37973789 except StopAsyncIteration :
37983790 pass
37993791
3800- try :
3801- async with anyio .create_task_group () as task_group :
3802- task_group .start_soon (drive )
3803- with anyio .fail_after (5 ):
3804- await lock .waiting .wait ()
3805- oauth_provider .context .token_expiry_time = time .time () + 3600
3806- lock .release ()
3807- finally :
3808- if lock .locked ():
3809- lock .release ()
3792+ async with anyio .create_task_group () as task_group :
3793+ task_group .start_soon (drive )
3794+ with anyio .fail_after (5 ):
3795+ await lock .waiting .wait ()
3796+ oauth_provider .context .token_expiry_time = time .time () + 3600
3797+ await lock .__aexit__ (None , None , None )
38103798
38113799 assert len (sent ) == 1
38123800 assert sent [0 ].method == "GET"
0 commit comments