Comments (4)
This feature request is extremely harmful.
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.
from filelock.
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.
Currently I'm using the following:
lock_path = out_path + ".lock"
lock = FileLock(lock_path)
try:
with lock.acquire(timeout=10):
...
except Timeout as e:
....
Looking at the source it appears that you removed this functionality again?
https://filelock.readthedocs.io/en/latest/_modules/filelock.html#UnixFileLock
from filelock.
Ups, there's no reason for that, I simply forgot to clean up.
Thank you for the patch!
from filelock.
3.0.12
affected. Please reopen. SoftFileLock
works as expected.
from filelock.
Related Issues (20)
- [regression] 12 tests fail with version 3.12.3, 0 tests were failing with version 3.12.2 HOT 1
- typing-extensions is a dependency but is not needed at runtime HOT 5
- Bug: Reentrant behavior does not work with distinct lock objects on the same thread HOT 4
- Using filelock in docker HOT 1
- Allow disabling fcntl (and use softfilelock) with environment variable HOT 2
- Python 3.7 support dropoff at version 3.12.3 not reflected in 'Security' section HOT 1
- Request add `RwLock` HOT 1
- Add cancellation tokens support
- Demo usage in the documentation is uncommon and misleading HOT 2
- Deadlock when a process tries to open and lock on the same file twice HOT 5
- Suggestion on documentation improvement over SoftFileLock
- 6 tests fail HOT 6
- is_singleton=True with nested lock hangs HOT 1
- Release to PyPi is failing HOT 1
- AttributeError: '_CountedFileLock' object has no attribute 'thread_safe' HOT 2
- '_CountedFileLock' object has no attribute 'thread_safe' HOT 34
- the latest filelock package 3.15.1 has compatible issue with package virtualenv HOT 6
- Poetry build fails with new filelock bugfix version HOT 9
- TypeError: LockedJSONData.__init__() got an unexpected keyword argument 'lock_file' ; regression between 3.15.1 and 3.15.3 HOT 3
- Android/Termux doesn't have flock, use lockf, SoftFileLock, or no lock? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filelock.