Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #21

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading