You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After they are released, an attempt is made to delete the lock files in both the WindowsFileLock and SoftFileLock classes, but not in UnixFileLock. Is there a reason this is missing from UnixFileLock? It seems strange that lock files clean up after themselves on some systems but not on others.
I'm not sure if I'm doing this incorrectly but it appears that this is happening again on Ubuntu for version 3.0.4. I can see the debug messages coming through and it seems to be acquiring, locking, and releasing correctly, but there are a bunch of .lock files still laying around.
Deleting lockfiles on UNIX causes a race condition. Consider the following set of events:
Program A creates and opens (as an atomic operation) a file A.lck.
Program A grabs a lock on the file handle it holds on that file; this operation succeeds.
Program B opens A.lck.
Program B requests a lock on the file handle; this operation blocks.
Program A deletes A.lck.
Program A closes its file handle, which makes program B able to get a lock on the file handle it already holds, on the now-deleted copy of A.lck.
Program C creates and opens (as an atomic operation) a new file under the name A.lck.
Program C grabs a lock on the file handle it holds on this file; because they're two different files (even if under the same name), this succeeds.
...thus, you have both programs B and C thinking they hold the same lock.
On Windows this can't happen, because directory entries can't be deleted until no handles on the files that back them exist. That's untrue on UNIX; thus, different behavior is required.
Reacted by Kirill Bulygin, xuyang2, Jürgen Löhel and Antoine Broyelle
Activity
AdorablePotato commentedon Dec 28, 2017
Ups, there's no reason for that, I simply forgot to clean up.
Thank you for the patch!
*updated* major version number due to issue #29 and issue #27
RPiAwesomeness commentedon May 31, 2018
I'm not sure if I'm doing this incorrectly but it appears that this is happening again on Ubuntu for version 3.0.4. I can see the debug messages coming through and it seems to be acquiring, locking, and releasing correctly, but there are a bunch of
.lockfiles still laying around.Currently I'm using the following:
Looking at the source it appears that you removed this functionality again?
https://filelock.readthedocs.io/en/latest/_modules/filelock.html#UnixFileLock
int-ua commentedon Jun 26, 2019
3.0.12affected. Please reopen.SoftFileLockworks as expected.charles-dyfis-net commentedon Sep 27, 2019
This feature request is extremely harmful.
Deleting lockfiles on UNIX causes a race condition. Consider the following set of events:
A.lck.A.lck.A.lck.A.lck.A.lck....thus, you have both programs B and C thinking they hold the same lock.
On Windows this can't happen, because directory entries can't be deleted until no handles on the files that back them exist. That's untrue on UNIX; thus, different behavior is required.