From 97c40a5d25356604003548ae3335bb6f85ba04d6 Mon Sep 17 00:00:00 2001 From: joshuaalbert Date: Sun, 28 Jan 2024 21:24:16 +0530 Subject: [PATCH 1/2] * Add support for 3.12 --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index d383841..809227a 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] + python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] steps: - uses: actions/checkout@v3 From 19006b1c175bd0508d323f4d245ee867f0a1cf77 Mon Sep 17 00:00:00 2001 From: joshuaalbert Date: Thu, 17 Oct 2024 00:04:55 +0200 Subject: [PATCH 2/2] * Do #23 --- fair_async_rlock/fair_async_rlock.py | 3 +++ fair_async_rlock/tests/test_fair_async_rlock.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/fair_async_rlock/fair_async_rlock.py b/fair_async_rlock/fair_async_rlock.py index 46067f2..931ca5c 100644 --- a/fair_async_rlock/fair_async_rlock.py +++ b/fair_async_rlock/fair_async_rlock.py @@ -22,6 +22,9 @@ def is_owner(self, task=None): task = asyncio.current_task() return self._owner == task + def locked(self) -> bool: + return self._owner is not None + async def acquire(self): """Acquire the lock.""" me = asyncio.current_task() diff --git a/fair_async_rlock/tests/test_fair_async_rlock.py b/fair_async_rlock/tests/test_fair_async_rlock.py index 9abbb7f..89a220c 100644 --- a/fair_async_rlock/tests/test_fair_async_rlock.py +++ b/fair_async_rlock/tests/test_fair_async_rlock.py @@ -652,3 +652,13 @@ async def task3(): t3 = asyncio.create_task(task3()) await asyncio.gather(t1, t2, t3) + +@pytest.mark.asyncio +def test_locked(): + lock = FairAsyncRLock() + assert not lock.locked() + async def task(): + async with lock: + assert lock.locked() + asyncio.run(task()) + assert not lock.locked() \ No newline at end of file