Skip to content

Commit 41d2cf7

Browse files
committed
chore: try to use a normal RLock arround aquiring an async lock
1 parent 9790823 commit 41d2cf7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

robotcode/utils/async_tools.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,28 +458,28 @@ async def acquire(self) -> bool:
458458
fut = create_sub_future()
459459
self._waiters.append(fut)
460460

461-
try:
462461
try:
462+
try:
463463

464-
def aaa(fut: asyncio.Future[Any]) -> None:
465-
warnings.warn(f"Lock {self} takes to long {threading.current_thread()}\n, try to cancel...")
466-
fut.cancel()
464+
def aaa(fut: asyncio.Future[Any]) -> None:
465+
warnings.warn(f"Lock {self} takes to long {threading.current_thread()}\n, try to cancel...")
466+
fut.cancel()
467467

468-
h = fut.get_loop().call_later(120, aaa, fut)
469-
try:
470-
await fut
468+
h = fut.get_loop().call_later(120, aaa, fut)
469+
try:
470+
await fut
471+
finally:
472+
h.cancel()
471473
finally:
472-
h.cancel()
473-
finally:
474-
with self._lock:
475-
self._waiters.remove(fut)
476-
except asyncio.CancelledError:
477-
with self._lock:
474+
with self._lock:
475+
self._waiters.remove(fut)
476+
except asyncio.CancelledError:
477+
# with self._lock:
478478
if not self._locked:
479479
self._wake_up_first()
480480
raise
481481

482-
with self._lock:
482+
# with self._lock:
483483
self._locked = True
484484
self._locker = asyncio.current_task()
485485

0 commit comments

Comments
 (0)