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

try to non-block locking of a filelock is very long #65

Open
awaizman1 opened this issue Apr 2, 2020 · 1 comment
Open

try to non-block locking of a filelock is very long #65

awaizman1 opened this issue Apr 2, 2020 · 1 comment

Comments

@awaizman1
Copy link

Hi,

OS: Win10/7
Python: 3.6.8
py-filelock: 3.0.12

I try to acquire a filelock without blocking (i.e. timeout=0). when the file is locked this operation takes 1sec (although should return immediately).
I did dome deep dive here and figured out that the reason is msvcrt.locking function (which implemented using _locking - even in a pure C++ project it takes 1sec to try acquire already locked file using _locking.

Using winapi LockFile doesn't have this problem - it returns immediately when the file is already locked .
Do you think it worth change py-filelock implementation to use LockFile instead of _locking?

in my usecase, i'm trying to acquire the lock but if it is already locked I can ignore it and so other stuff. paying 1sec for each such check is crucial for me.

Thanks!

@awaizman1
Copy link
Author

awaizman1 commented Apr 5, 2020

suggested PR #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants