-
-
Notifications
You must be signed in to change notification settings - Fork 906
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
Race condition in multithreading environment due to usage of os.chdir #1052
Comments
Thanks for the detailed report. I am leaving it open for others to find, despite having no hopes of this being tackled. Generally, GitPython is not thread-safe, but if desired, certain types of actions cold be made to allow multiple threads under the condition that these operate on their own repositories. |
Seems like the mentioned decorator is only used to protect calls to _store_path. Would it be difficult to ensure that this function does system calls only on absolute paths and performs conversion to relative names (to add to git) by path manipulation (prefix stripping)? |
That should definitely be possible. The reason it is currently implemented like this is simplicity: delegating all path handling to the operating system (the devil is in the details especially when windows is involved). |
Ah ... didn't think about multi-platforming at all :( . Thanks for the explanation ! |
Hi,
I recently ran into a race condition when using two different instances of
git.Repo
objects in two different threads.Inside
repo.index.add()
, some functions are decorated with thegit_working_dir
decorator. This decorator changes the process working directory to the one of repository, performs some system calls, then returns the working dir back to the initial value.If two threads perform
repo.index.add()
, even on two independentRepo()
objects, the working directory of the entire process could be permanently modified. Moreover, system calls done byindex.add()
may fail. For examplelstat()
will be executed with a relative file name assuming a wrong absolute path.For example:
now the process wd is /repo1
I believe I could work around this issue by creating git object directly rather than adding to the index then committing, but I thought you may be interested to know about the issue.
Radu
The text was updated successfully, but these errors were encountered: