-
-
Notifications
You must be signed in to change notification settings - Fork 115
SQLite-based read-write lock #399
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
base: main
Are you sure you want to change the base?
Conversation
src/filelock/_read_write.py
Outdated
super().__init__(lock_file, timeout, blocking) | ||
self.procLock = threading.Lock() | ||
self.con = sqlite3.connect(self._context.lock_file, check_same_thread=False) | ||
# Redundant unless there are "rogue" processes that open the db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align comments to 120 charachters 🙇
src/filelock/_read_write.py
Outdated
|
||
|
||
class _SQLiteLock(BaseFileLock): | ||
def __init__(self, lock_file: str | os.PathLike[str], timeout: float = -1, blocking: bool = True) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer
from os import PathLike
@gaborbernat I've pushed a more "serious" attempt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, can you add tests please?
@gaborbernat what do you think about using SQLite's VFS interface directly, without the "dummy database" thing? https://github.com/rogerbinns/apsw provides bindings |
It's important that we have no dependencies. The only alternative could be
to hide this functionality behind some extra, I do not know how widely
available the bindings are in form of wheels.
…On Mon, Feb 24, 2025, 21:58 Roman Leventov ***@***.***> wrote:
@gaborbernat <https://github.com/gaborbernat> what do you think about
using SQLite's VFS interface <https://www.sqlite.org/vfs.html> directly,
without the "dummy database" thing? https://github.com/rogerbinns/apsw
provides bindings
—
Reply to this email directly, view it on GitHub
<#399 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFIQPULETXMCF2DNC5TAZD2RQA7HAVCNFSM6AAAAABXO35KTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBQGY4TIOBZG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: leventov]*leventov* left a comment (tox-dev/filelock#399)
<#399 (comment)>
@gaborbernat <https://github.com/gaborbernat> what do you think about
using SQLite's VFS interface <https://www.sqlite.org/vfs.html> directly,
without the "dummy database" thing? https://github.com/rogerbinns/apsw
provides bindings
—
Reply to this email directly, view it on GitHub
<#399 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFIQPULETXMCF2DNC5TAZD2RQA7HAVCNFSM6AAAAABXO35KTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBQGY4TIOBZG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
for more information, see https://pre-commit.ci
@gaborbernat I've added tests. If you want to finesse API (context managers vs. parameters to acquire_read() and acquire_write() methods; are read_lock() and write_lock() methods even needed? Are instance's default timeout and blocking needed?), docs, formatting, class/method naming, etc., could you please do it yourself to your liking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failing.
@gaborbernat I don't need this PR to be merged to use it later through What of these seem valid to you, and what seem like false positives?
Can the CI auto-fix from check / test pypy3.10 - windows-latest is test-suite related, perhaps even CI environment-related. |
Moved to draft until we fix the issues. |
Draft for #307.
@gaborbernat @Yard1 please let me know how I should change the code from the API perspective. There are quite a bit very elaborate stuff that is hard to understand regarding thread-locals, etc.