-
-
Notifications
You must be signed in to change notification settings - Fork 934
BrokenPipeError on KeyboardInterrupt #427
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
Comments
Thanks for the report ! I was able to reproduce the issue, and also found a workaround for now. What you can do is to use a different object database implementation when instantiating the repo like so: repository = Repo('.', odbt=git.GitDB) The default object database implementation changed between the versions of gitpython, from the one you see above (pure python) to one that uses a long-running git subprocess to stream objects. The latter is faster and generally preferred, but apparently interacts badly with certain signals. As GitPython is in maintenance mode and has no functional test suite just yet (which I would need to test these interaction to find a fix), I will leave this one open hoping that others with a similar issue find it (and the workaround). |
I've also found another workaround, where I create a new |
Add a summary of the commits that influenced this tag Also fix a problem with gitpython implementation, more information gitpython-developers/GitPython#427
We'll be using `git diff` soon, which the subprocess-based DB implementation cannot handle (throws a "Broken pipe" error): gitpython-developers/GitPython#427 Signed-off-by: Danny Lin <danny@kdrag0n.dev>
We'll be using `git diff` soon, which the subprocess-based DB implementation cannot handle (throws a "Broken pipe" error): gitpython-developers/GitPython#427 Signed-off-by: Danny Lin <danny@kdrag0n.dev>
# Context: USER: when printing the git repo name, print it relative to cwd ASSISTANT: To print the git repo name relative to the current working directory, you can modify the `set_repo` function in the `aider/coder.py` file. Here's the change: ```python aider/coder.py <<<<<<< ORIGINAL if num_repos == 0: self.io.tool_error("Files are not in a git repo.") return if num_repos > 1: self.io.tool_error("Files are in different git repos.") return # gitpython-developers/GitPython#427 repo = git.Repo(repo_paths.pop(), odbt=git.GitDB) self.root = repo.working_tree_dir self.io.tool("Using git repo:", self.repo.git_dir) ======= if num_repos == 0: self.io.tool_error("Files are not in a git repo.") return if num_repos > 1: self.io.tool_error("Files are in different git repos.") return # gitpython-developers/GitPython#427 repo = git.Repo(repo_paths.pop(), odbt=git.GitDB) self.root = repo.working_tree_dir rel_repo_dir = os.path.relpath(self.repo.git_dir, os.getcwd()) self.io.tool("Using git repo:", rel_repo_dir) >>>>>>> UPDATED ``` This change replaces `self.repo.git_dir` with `os.path.relpath(self.repo.git_dir, os.getcwd())` to display the git repo path relative to the current working directory.
I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to newer versions of GitPython. Consider the following snippet (assumes a git repository on the current directory):
If you interrupt (Ctrl+C) the loop, then the last statement fails with a broken pipe exception (full stack trace below). If the code is not interrupted everything succeeds. Also removing the
current_commit = repository.head.commit
line, makes the problem go away, even if you interrupt a loop.I presume that it has to do with the handling of the SIGTERM emitted with a Ctrl+C, but I am not sure if this is true.
The stack trace:
Some more context: I am using GitPython for
experimenter
link and need a way to handleKeyboardInterruption
s. When a Ctrl+C is pressed, I want to be able to safely store data into the git repository.The text was updated successfully, but these errors were encountered: