mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 09:20:57 +01:00
Merge pull request #2600 from xonsh/checkend
Fixed process hanging issue.
This commit is contained in:
commit
ca483703c3
2 changed files with 19 additions and 3 deletions
14
news/checkend.rst
Normal file
14
news/checkend.rst
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
**Added:** None
|
||||||
|
|
||||||
|
**Changed:** None
|
||||||
|
|
||||||
|
**Deprecated:** None
|
||||||
|
|
||||||
|
**Removed:** None
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* Fixed hanging issue with pipelines whose middle processes exit before the
|
||||||
|
first or last process.
|
||||||
|
|
||||||
|
**Security:** None
|
|
@ -2062,16 +2062,18 @@ class CommandPipeline:
|
||||||
"""Boolean for if all previous processes have completed. If there
|
"""Boolean for if all previous processes have completed. If there
|
||||||
is only a single process in the pipeline, this returns False.
|
is only a single process in the pipeline, this returns False.
|
||||||
"""
|
"""
|
||||||
|
any_running = False
|
||||||
for s, p in zip(self.specs[:-1], self.procs[:-1]):
|
for s, p in zip(self.specs[:-1], self.procs[:-1]):
|
||||||
|
if p.poll() is None:
|
||||||
|
any_running = True
|
||||||
|
continue
|
||||||
self._safe_close(p.stdin)
|
self._safe_close(p.stdin)
|
||||||
self._safe_close(s.stdin)
|
self._safe_close(s.stdin)
|
||||||
if p.poll() is None:
|
|
||||||
return False
|
|
||||||
self._safe_close(p.stdout)
|
self._safe_close(p.stdout)
|
||||||
self._safe_close(s.stdout)
|
self._safe_close(s.stdout)
|
||||||
self._safe_close(p.stderr)
|
self._safe_close(p.stderr)
|
||||||
self._safe_close(s.stderr)
|
self._safe_close(s.stderr)
|
||||||
return len(self) > 1
|
return False if any_running else (len(self) > 1)
|
||||||
|
|
||||||
def _close_prev_procs(self):
|
def _close_prev_procs(self):
|
||||||
"""Closes all but the last proc's stdout."""
|
"""Closes all but the last proc's stdout."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue