Skip to content

Commit

Permalink
Merge pull request #21 from Joshuaalbert/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Joshuaalbert authored Oct 16, 2024
2 parents bad409d + d1299ec commit 7c3ed4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions fair_async_rlock/fair_async_rlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions fair_async_rlock/tests/test_fair_async_rlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 7c3ed4e

Please sign in to comment.