Skip to content

Check that lock file exists, before trying to delete it. #20

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

Merged
merged 2 commits into from
Jul 9, 2017

Conversation

denpamusic
Copy link
Contributor

@denpamusic denpamusic commented Jul 7, 2017

This need to be done, because when using FileLock::BLOCKING locking method, if there two separate process acquiring the same lock, when one finishes it deletes lock file, when next one finishes it throws "No such file or directory" exception, since lock file no longer exists.

@mathroc
Copy link
Member

mathroc commented Jul 7, 2017

thank you @denpamusic , can you add a test for this please ?

@denpamusic
Copy link
Contributor Author

I'll try later this evening or on weekends. It'll be hard though, as php-vfs used for testing doesn't support blocking locks, as mentioned in the notes here: michael-donat/php-vfs#32.
I use php-lock run one crontab task at the time. Cron jobs I use tend to run only for 2-3 seconds every minute, blocking locks are great in this case, since locked process just waits for a few seconds instead of failing with exception and waiting for a whole minute.

@mathroc
Copy link
Member

mathroc commented Jul 7, 2017

you don’t need blocking lock for the test, you only have to acquire a lock, manually remove the file and release the lock

@denpamusic
Copy link
Contributor Author

Thank you! It's easy then.

@mathroc mathroc merged commit 037ff0b into texthtml:master Jul 9, 2017
@mathroc
Copy link
Member

mathroc commented Jul 9, 2017

thank you @denpamusic

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

Successfully merging this pull request may close these issues.

2 participants