mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
commit
90384c3064
2 changed files with 17 additions and 3 deletions
|
@ -41,12 +41,15 @@
|
|||
in favor of a more general mechanism for dispatching callable aliases
|
||||
implemented in the ``ProcProxyThread`` and ``ProcProxy`` classes.
|
||||
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* May now Crtl-C out of an infinite loop with a subprocess, such as
|
||||
```while True: sleep 1``.
|
||||
* Fix for stdin redirects.
|
||||
* Backgrounding works with ``$XONSH_STORE_STDOUT``
|
||||
* Added a minimum time buffer time for command pipelines to check for
|
||||
if previous commands have executed successfully. This is helpful
|
||||
for pipelines where the last command takes a long time to start up,
|
||||
such as GNU Parallel.
|
||||
|
||||
**Security:** None
|
||||
|
|
|
@ -1468,18 +1468,29 @@ class CommandPipeline:
|
|||
stderr = stderr.buffer
|
||||
# read from process while it is running
|
||||
timeout = builtins.__xonsh_env__.get('XONSH_PROC_FREQUENCY')
|
||||
check_prev_done = len(self.procs) == 1
|
||||
while proc.poll() is None:
|
||||
if getattr(proc, 'suspended', False):
|
||||
return
|
||||
elif getattr(proc, 'in_alt_mode', False):
|
||||
time.sleep(0.1) # probably not leaving any time soon
|
||||
continue
|
||||
elif not check_prev_done:
|
||||
# In the case of pipelines with more than one command
|
||||
# we should give the commands a little time
|
||||
# to start up fully. This is particularly true for
|
||||
# GNU Parallel, which has a long startup time.
|
||||
pass
|
||||
elif self._prev_procs_done():
|
||||
self._close_prev_procs()
|
||||
proc.prevs_are_closed = True
|
||||
break
|
||||
yield from safe_readlines(stdout, 1024)
|
||||
self.stream_stderr(safe_readlines(stderr, 1024))
|
||||
stdout_lines = safe_readlines(stdout, 1024)
|
||||
yield from stdout_lines
|
||||
stderr_lines = safe_readlines(stderr, 1024)
|
||||
self.stream_stderr(stderr_lines)
|
||||
if not check_prev_done and (stdout_lines or stderr_lines):
|
||||
check_prev_done = True
|
||||
time.sleep(timeout)
|
||||
# read from process now that it is over
|
||||
yield from safe_readlines(stdout)
|
||||
|
|
Loading…
Add table
Reference in a new issue