Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filelock expiration #68

Open
beasteers opened this issue Apr 23, 2020 · 6 comments
Open

filelock expiration #68

beasteers opened this issue Apr 23, 2020 · 6 comments

Comments

@beasteers
Copy link

To avoid the case where lock files accidentally get left and lock things forever, we could have the process that acquires the lock set an expiration time on the lock. and if it's expired, the other process can assume that the process died or something and delete and re-acquire the lock.

@Jingnan-Jia
Copy link

I guess you can achieve it by yourself. For example, you can write a code: if waiting more than 1 hour, just delete the lock file, and retry to acquire the lock.

@gaborbernat
Copy link
Member

Hello, if you make a PR for this (with tests) we would be happy to review it, thanks!

@gaborbernat gaborbernat changed the title [Feature Request] filelock expiration filelock expiration Sep 27, 2021
@rayosborn
Copy link

I am interested in this feature and was wondering how to implement it myself. Is there a recognized method for checking the lock file modification time and then removing it without the danger of race conditions?

@gaborbernat
Copy link
Member

Not that I'm aware of, you'd likely have to do the research and then implement it 😂

@rayosborn
Copy link

I was afraid of that. So far, I have not been successful in my investigations and I don't have any expertise in Posix filesystem arcana. In fact, it was Googling this topic that led me to your module.

@TheMatt2
Copy link
Contributor

TheMatt2 commented Apr 9, 2023

Perhaps a new PIDLock could be defined that saves the pid of the lock.
If the lock is held by a pid that no longer exists, the the lock is destroyed.
The trick is doing this in a race-condition free manner.

Perhaps this is a starting point? https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants