Closed
Description
Task:
Clone from a remote repository having ssh://abc@domain.com/git/remote_repo format, which has submodules included from the outside of domain.com.
Problem:
current_repository = git.Repo.clone_from(r"ssh://abc@domain.com/git/remote_repo", r"d:\temp")
the remote_repo has 313 objects (files and folders). Above method call hangs after fetching 294 objects. Total size of remote_repo is 82 MB.
Observations:
- Command Prompt: "git clone -v ssh://abc@domain.com/git/remote_repo d:\temp" works
- Git Bash: "git clone -v ssh://abc@domain.com/git/remote_repo d:\temp" works
- Python interpreter: os.system("git clone -v ssh://abc@domain.com/git/remote_repo d:\temp") works
Possible but incomplete solution:
there is some problem with stderr=PIPE parameter of subprocess.Popen call in execute method of Python27\Lib\site-packages\GitPython-0.3.2.RC1-py2.7.egg\git\cmd.py.
If I change the code to below:
err_file = open("d:\\err.txt","w")
# Start the process
proc = Popen(command,
cwd=cwd,
stdin=istream,
stderr=err_file,
#stderr=PIPE,
stdout=PIPE,
close_fds=(os.name=='posix'),# unsupported on linux
**subprocess_kwargs
)
The process does not hang.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
Issue gitpython-developers#72 gitpython-developers#72
Issue gitpython-developers#72 gitpython-developers#72
hagdog commentedon Aug 28, 2013
I am having the same problem. I tried the solution posted above and the clone command starts working.
I am sure that this workaround cannot be used permanently since stderr would always be compromised.
Is there, perhaps, a workaround that can be applied in a script that uses gitpython? I tried various things like closing or re-directing stderr in my script. Nothing worked.
Environment: 64-bit, Windows 7, Service Pack 1, gitpython-0.3.2.rc1.
Byron commentedon Aug 29, 2013
I have recently written other process-handling code and used a select loop to read both channels in a single thread without blocking. This is what one should do here as well.
hagdog commentedon Sep 4, 2013
Thanks for the suggestion, Byron. Unfortunately, this will not work on Windows. Well, at least the way I tried it:
So, the documentation is accurate, you can only select sockets in Windows, i.e. something that came from winsock.
Byron commentedon Nov 19, 2014
The git process handling is a major point of improvement in 0.3.5, as it is causing plenty of issues and has not been fixed sufficiently well yet.
Byron commentedon Jan 7, 2015
Process handling was improved to the point where pipes are unable to run full and block.
Please see the related ticket #145 .
timblechmann commentedon Feb 5, 2016
@Byron unfortunately we've still seen this issue with gitpython 1.0.1 on windows. i didn't follow all the codepaths, but using
quiet=True
for myfetch
andclone_from
calls resoves this issue, so there must still be something fishy :/i'm not exactly familiar with the implementation, but https://github.com/gitpython-developers/GitPython/blob/master/git/cmd.py#L661 still seems to have a codepath, which doesn't use the
.communicate
API ...fix(clone): call communicate if there is no progress handler
fix(cmd): prevent deadlock on clone/fetch/pull
Byron commentedon Feb 7, 2016
Indeed, by looking at the code linked by you, I'd think that a deadlock is possible here. However, it seems that this functionality is used just once in an unrelated command.
When looking at the code-path taken by fetch/pull, it becomes apparent that it will enforce opening stdout, even though it never reads from it - this could be the deadlock you experience.
The
clone_from
codepath could have the same problem unless a progress-handler is used. A change was made that could fix the clone-issue.A few changes have been made, and you are welcome to test them with your setup. In case it works, please let me know.