Github user rhtyd commented on the pull request: https://github.com/apache/cloudstack/pull/1408#issuecomment-215217268 @wido I tested your original PR and the current updated PR, the locking never happened on my test env (Ubuntu x64). I read the manpage, and found that when you open a file twice `flock` will treat both FDs independently while `fcntl` (the lockf usage) treats them as FDs. This means that when two processes could run the python script at the same time, no locking would actually occur. I wrote a test program to demonstrate this: (for testing you may replace flock with lockf and see for yourself that it does not lock at all) https://gist.github.com/rhtyd/5d9983e7d58311ba8e517eefd931a507 So, my suggestion is to: - use flock instead of lockf, assuming and likely the file exists on local filesystem we can use `flock` with no issues - use the previously used open instead of with open, as with open syntax closes file when the statements under it return
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---