Coder Social home page Coder Social logo

Comments (4)

charles-dyfis-net avatar charles-dyfis-net commented on July 26, 2024 3

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.

RPiAwesomeness avatar RPiAwesomeness commented on July 26, 2024 1

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.

AdorablePotato avatar AdorablePotato commented on July 26, 2024

Ups, there's no reason for that, I simply forgot to clean up.
Thank you for the patch!

from filelock.

int-ua avatar int-ua commented on July 26, 2024

3.0.12 affected. Please reopen. SoftFileLock works as expected.

from filelock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.