File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async def check(lock: AsyncLock):
1717
1818async def amain ():
1919 lock = AsyncLock ()
20- with threaded_loop () as tl1 , threaded_loop () as tl2 :
20+ with threaded_loop (use_eager_task_factory = False ) as tl1 , threaded_loop (use_eager_task_factory = False ) as tl2 :
2121 tsks = {loop .run (check (lock )) for loop in (tl1 , tl2 ) for _ in range (10 )}
2222 await asyncio .gather (* tsks )
2323
Original file line number Diff line number Diff line change @@ -41,7 +41,11 @@ def __locked(self) -> bool:
4141 return self ._lockv or (any (not w .cancelled () for w in (self ._waiters )))
4242
4343 async def __aenter__ (self ) -> None :
44- await asyncio .sleep (0 ) # This yield is non-optional.
44+ # placing the body of acquire here
45+ # causes problems with eager tasks factories.
46+ await self .__acquire ()
47+
48+ async def __acquire (self ) -> None :
4549
4650 with self ._internal_lock :
4751 if not self .__locked ():
@@ -80,7 +84,6 @@ def _maybe_wake(self) -> None:
8084 break
8185
8286 async def __aexit__ (self , * dont_care : object ) -> t .Literal [False ]:
83- await asyncio .sleep (0 ) # this yield is not optional
8487 with self ._internal_lock :
8588 self ._lockv = False
8689 self ._maybe_wake ()
You can’t perform that action at this time.
0 commit comments