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

asyncio support #332

Merged
merged 12 commits into from
Jun 11, 2024
Merged

asyncio support #332

merged 12 commits into from
Jun 11, 2024

Conversation

Ovizro
Copy link
Contributor

@Ovizro Ovizro commented Jun 3, 2024

Add asyncio support for filelock

Usage:

import asyncio
from filelock import AsyncFileLock

async def main() -> None:
    lock = AsyncFileLock("test.lock")
    async with lock:
        print("Lock acquired")
        await asyncio.sleep(1)

asyncio.run(main())

The default asynchronous approach in this implementation is to execute _acquire and _release in the thread pool.
Please ask if this is how you would like to see it implemented. If you think this is feasible, I will make further modifications and add tests for it.

@gaborbernat gaborbernat marked this pull request as draft June 4, 2024 00:39
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failing and no tests.

@Ovizro Ovizro marked this pull request as ready for review June 4, 2024 07:54
@Ovizro Ovizro requested a review from gaborbernat June 6, 2024 06:14
pyproject.toml Outdated Show resolved Hide resolved
@Ovizro Ovizro requested a review from gaborbernat June 6, 2024 07:09
src/filelock/asyncio.py Outdated Show resolved Hide resolved
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat gaborbernat enabled auto-merge (squash) June 11, 2024 16:43
@gaborbernat gaborbernat merged commit 87453f3 into tox-dev:main Jun 11, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants