filelock icon indicating copy to clipboard operation
filelock copied to clipboard

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

Open awaizman1 opened this issue 5 years ago • 1 comments

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 avatar Apr 02 '20 12:04 awaizman1

suggested PR #66

awaizman1 avatar Apr 05 '20 08:04 awaizman1