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)
- filelock 3.10.0 changes umask to 0 in multithreaded processes, causing world-writable files to be created HOT 23
- Today after after this change poetry installs in Docker/Podman containers started to fail (it depends on filelock which was bumped from 3.10.0 to 3.10.12), from our CI log: HOT 5
- Update os.open to preserve mode= for certain edge cases.
- filelock_test does not catch faulty lock
- Test `test_filelock.py::test_lock_mode_soft` fails if default umask is 002 HOT 1
- document generation failing HOT 1
- filelock 3.11 breaks our multi-threaded parallel processing use case HOT 24
- 3.12.0: test_bad_lock_file[current_directory-UnixFileLock] fails HOT 6
- sdist is missing tox.ini HOT 1
- The type annotation for the `lock_file` `__init__` parameter is too narrow HOT 1
- Why can I acquire the same lock twice? HOT 2
- python 3.11 support HOT 1
- [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
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.