Use flock() for file locking#513
Use flock() for file locking#513Byron merged 11 commits intogitpython-developers:masterfrom expobrain:master
Conversation
|
Hi Byron, I'm more than happy to add the Windows support of this PR. Do you have any guidelines on how to develop and test GitPython on Windows? |
|
@expobrain Thanks a lot in advance ! Any help is appreciated and welcome. There are not many requirements when getting started contributing, and the few things there are have been added to the contribution guide. @ankostis Is working on integrating GitPython with AppVeyor as CI for windows in PR #519, which I believe would be very beneficial for you to have. Alternatively, you just get started and focus on the tests that verify the locking specifically. Once they run on your machine locally, you could just push them into your PR to have travis verify nothing broke on the linux side. I hope you find this answer helpful, and that you can get started painlessly. |
|
#519 is a gargatuan PR that I've been working for almost 2 weeks. |
|
@expobrain can you rebase on master now that #519 is merged? |
391a767 to
8a2f7dc
Compare
Conflicts: git/util.py
|
Yes, doing it now |
|
Thanks a lot for your contribution, and to everyone else who has contributed to this PR ! |
|
@Byron Appveyor fails on this :-( https://ci.appveyor.com/project/ankostis/gitpython/build/1.0.225 Have you logged-into Appveyor and add this project? |
|
@Byron This PR had caused me many Windows problems downstream - please revert. @expobrain If the old locking-code is problematic, we may look also into this alternative library: https://github.com/pakal/rsfile/blob/master/doc/locking_semantic.rst But I really miss an explanation what was the problem with the old code (add it in the OP). |
|
Actually this PR has been reverted. @expobrain if you feel like you can address some of the issue we can revisit this one; but please first explain what was the problem with the old code. |

The problem with the original code is that the lock was based on the presence of the lockfile, that is if the lockfile exists the _obtain_lock() fails otherwise it succeed on acquiring the lock.
However this was problematic because between the check if the lockfile exists and the creation of the file another process can create the file as well resulting in a double lock, and we don't want to lock the same file twice :-)