@@ -425,6 +425,7 @@ def __init__(self) -> None:
425425 self ._waiters : Optional [Deque [asyncio .Future [Any ]]] = None
426426 self ._locked = False
427427 self ._lock = threading .RLock ()
428+ self ._locker : Optional [asyncio .Task [Any ]] = None
428429
429430 async def __aenter__ (self ) -> None :
430431 await self .acquire ()
@@ -439,7 +440,7 @@ def __repr__(self) -> str:
439440 extra = "locked" if self ._locked else "unlocked"
440441 if self ._waiters :
441442 extra = f"{ extra } , waiters:{ len (self ._waiters )} "
442- return f"<{ res [1 :- 1 ]} [{ extra } ]>"
443+ return f"<{ res [1 :- 1 ]} [{ extra } ]> { self . _locker } "
443444
444445 @property
445446 def locked (self ) -> bool :
@@ -449,6 +450,7 @@ async def acquire(self) -> bool:
449450 with self ._lock :
450451 if not self ._locked and (self ._waiters is None or all (w .cancelled () for w in self ._waiters )):
451452 self ._locked = True
453+ self ._locker = asyncio .current_task ()
452454 return True
453455
454456 if self ._waiters is None :
@@ -461,7 +463,7 @@ async def acquire(self) -> bool:
461463 try :
462464
463465 def aaa (fut : asyncio .Future [Any ]) -> None :
464- # warnings.warn(f"Lock takes to long {threading.current_thread()}\n{s} , try to cancel...")
466+ warnings .warn (f"Lock { self } takes to long { threading .current_thread ()} \n , try to cancel..." )
465467 fut .cancel ()
466468
467469 # h = fut.get_loop().call_later(120, aaa, "".join(traceback.format_stack()))
@@ -481,6 +483,7 @@ def aaa(fut: asyncio.Future[Any]) -> None:
481483
482484 with self ._lock :
483485 self ._locked = True
486+ self ._locker = asyncio .current_task ()
484487
485488 return True
486489
@@ -489,6 +492,7 @@ def release(self) -> None:
489492 wake_up = False
490493 if self ._locked :
491494 self ._locked = False
495+ self ._locker = None
492496 wake_up = True
493497
494498 if wake_up :
0 commit comments