Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac78d85

Browse filesBrowse files
committed
Issue #72 #72
Fix hanging when clone or pull execute See http://www.popekim.com/2008/12/never-use-pipe-with-python-popen.html
1 parent 0b820e6 commit ac78d85
Copy full SHA for ac78d85

1 file changed

+21-9Lines changed: 21 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/cmd.py‎

Copy file name to clipboardExpand all lines: git/cmd.py
+21-9Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import os, sys
8+
import tempfile
89
from util import (
910
LazyMixin,
1011
stream_copy
@@ -328,19 +329,30 @@ def execute(self, command,
328329
cwd = os.getcwd()
329330
else:
330331
cwd=self._working_dir
331-
332+
333+
if as_process:
334+
temp_file_err = tempfile.TemporaryFile()
335+
temp_file_out = tempfile.TemporaryFile()
336+
stderr_pipe=temp_file_err.fileno()
337+
stdout_pipe=temp_file_out.fileno()
338+
else:
339+
stderr_pipe=PIPE
340+
stdout_pipe=PIPE
341+
332342
# Start the process
333343
proc = Popen(command,
334-
cwd=cwd,
335-
stdin=istream,
336-
stderr=PIPE,
337-
stdout=PIPE,
338-
close_fds=(os.name=='posix'),# unsupported on linux
339-
**subprocess_kwargs
340-
)
344+
cwd=cwd,
345+
stdin=istream,
346+
stderr=stderr_pipe,
347+
stdout=stdout_pipe,
348+
close_fds=(os.name=='posix'),# unsupported on linux
349+
**subprocess_kwargs
350+
)
341351
if as_process:
352+
proc.stderr = temp_file_err
353+
proc.stdout = temp_file_out
342354
return self.AutoInterrupt(proc, command)
343-
355+
344356
# Wait for the process to return
345357
status = 0
346358
stdout_value = ''

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.