multiCMD 1.62__tar.gz → 1.63__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multicmd-1.62 → multicmd-1.63}/PKG-INFO +105 -10
- {multicmd-1.62 → multicmd-1.63}/README.md +104 -9
- {multicmd-1.62 → multicmd-1.63}/multiCMD.egg-info/PKG-INFO +105 -10
- {multicmd-1.62 → multicmd-1.63}/multiCMD.egg-info/SOURCES.txt +2 -0
- {multicmd-1.62 → multicmd-1.63}/multiCMD.py +205 -122
- {multicmd-1.62 → multicmd-1.63}/tests/test_cli_closed_stdout.py +93 -38
- multicmd-1.63/tests/test_cli_failed_stdout.py +485 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_display.py +75 -29
- {multicmd-1.62 → multicmd-1.63}/tests/test_interrupts.py +4 -1
- multicmd-1.63/tests/test_reader_quit.py +274 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_supervision.py +2 -2
- {multicmd-1.62 → multicmd-1.63}/LICENSE +0 -0
- {multicmd-1.62 → multicmd-1.63}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.62 → multicmd-1.63}/multiCMD.egg-info/entry_points.txt +0 -0
- {multicmd-1.62 → multicmd-1.63}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.62 → multicmd-1.63}/scripts/multiCMD +0 -0
- {multicmd-1.62 → multicmd-1.63}/setup.cfg +0 -0
- {multicmd-1.62 → multicmd-1.63}/setup.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_api.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_async_executor.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_cli.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_cli_input.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_cli_summary.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_embed.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_env.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_expand_ranges.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_handover.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_helpers.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_packaging.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_parsing.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_pass_fds.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_ping.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_pool.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_process_groups.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_pty.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_reader.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_regressions.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_run_command.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_run_commands.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_sudo.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_task.py +0 -0
- {multicmd-1.62 → multicmd-1.63}/tests/test_windows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.63
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -194,6 +194,7 @@ mcmd --shell -m 4 "dmesg | tail -n 5" "journalctl -n 5 > /tmp/j.log"
|
|
|
194
194
|
| Usage error (bad option, unbalanced quote, no commands) | `2` |
|
|
195
195
|
| Ctrl-C | `130` (`128+N` after SIGTERM / SIGHUP) |
|
|
196
196
|
| stdout has no reader (`mcmd ... \| head`) | ended by SIGPIPE, which a shell reports as `141`; `1` on Windows |
|
|
197
|
+
| stdout fails otherwise (a full disk; a terminal that hung up, on a job its hang-up does not signal) | the commands' own status, as if it had not: every command runs, and one line on stderr says the output was lost (unless stderr is the same dead target, as with `> log 2>&1` on a full disk: then the log just stops) |
|
|
197
198
|
|
|
198
199
|
### Input files and templates
|
|
199
200
|
|
|
@@ -444,15 +445,53 @@ Ctrl-C (or a SIGTERM handler's `sys.exit()`) in a call waiting on the main threa
|
|
|
444
445
|
and `AsyncExecutor.wait()` included, stops every command, skips the queued ones and
|
|
445
446
|
re-raises, giving them up to 5 s to exit; a second Ctrl-C ends that wait at once. `mcmd` stops its
|
|
446
447
|
commands on SIGTERM / SIGHUP (unless started with them ignored, as under `nohup`), and when its stdout
|
|
447
|
-
has no reader (`mcmd ... | head
|
|
448
|
-
nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
448
|
+
has no reader (`mcmd ... | head`, or a socket its peer closed or reset): it stops them as a Ctrl-C does, and ends by
|
|
449
|
+
SIGPIPE, as `yes | head` does, with nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
449
450
|
nothing more is stopped as well (`mcmd 'sleep 4' | head -2` ends at once); with any other stdout, and on Windows, it
|
|
450
|
-
learns it only when a write fails, and a command that prints nothing more runs to its end first
|
|
451
|
+
learns it only when a write fails, and a command that prints nothing more runs to its end first (on Windows that is a known
|
|
452
|
+
limitation, docs/limitations.md). ksh93 on Linux builds its
|
|
451
453
|
pipelines from sockets, so under it `mcmd ... | head` is the same: a write finds the reader gone, as in 1.61 (bash, dash, zsh,
|
|
452
|
-
mksh, busybox and macOS's ksh give a pipe). A
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
mksh, busybox and macOS's ksh give a pipe). A write to stdout that fails for any other reason (EIO from a terminal that
|
|
455
|
+
hung up, ENOSPC from a full disk; on Windows, EINVAL from anything but a pipe) loses only the output: `mcmd` drops it from
|
|
456
|
+
then on, runs every command, running and queued, says so in one line on stderr (`mcmd: cannot write to stdout ([Errno 5]
|
|
457
|
+
Input/output error): its output is dropped from here on`), if stderr can still take it, and exits with the commands' own
|
|
458
|
+
status, also with stdout and stderr on the same file. If stderr is that same dead target (`> log 2>&1` on a full disk), the
|
|
459
|
+
line is lost with the rest and the log just stops (it is written at exit if the target can take it by then). A stdout that
|
|
460
|
+
another program left non-blocking (`O_NONBLOCK`) fails with EAGAIN whenever its pipe or terminal is momentarily full, and
|
|
461
|
+
that counts as a failed write too: the output is dropped from then on. A program that imports multiCMD then never learns that
|
|
462
|
+
its reader quit: a shown `tail -f` runs on after `prog | head` has quit (`mcmd` asks the pipe, as above, and stops; see
|
|
463
|
+
docs/limitations.md). A terminal that hangs up also sends SIGHUP to the job in its foreground (a closed terminal window, or `ssh -t` whose connection drops), and bash and
|
|
464
|
+
zsh pass it on to every job they started, in the background too (dash does not): that stops the commands as before, and
|
|
465
|
+
`mcmd` ends `129`. A job nobody signals runs to its end: one that was `disown`ed, started with `setsid` or `nohup`, or, in
|
|
466
|
+
bash and dash, left in the background by `exit` (zsh signals its jobs on `exit` too). Over `ssh` without a pty, stdout is a
|
|
467
|
+
pipe to sshd, and a dropped connection closes it: a reader that quit. So a run that must outlive its terminal or its
|
|
468
|
+
connection, whatever starts it, runs under `nohup` (against the hang-up's SIGHUP) with its stdout in a file (which no
|
|
469
|
+
hang-up or dropped connection can close): `nohup mcmd -q ... > log 2>&1 &`. A program that imports multiCMD follows the same
|
|
470
|
+
rule for the writes of multiCMD's own output (its live output, `print_progress_bar()`, the report of `AsyncExecutor.join()`),
|
|
471
|
+
and none of those writes raises an `OSError` in the thread that wrote (a `sys.stdout` the program closed itself still gives
|
|
472
|
+
`ValueError`, as in 1.62: deferred to 1.64, docs/limitations.md). A reader that quit (`BrokenPipeError`, `ConnectionResetError`, or on
|
|
473
|
+
Windows `OSError` EINVAL from a pipe) stops the calls that are showing their commands (not quiet): their commands are
|
|
474
|
+
stopped as a Ctrl-C stops them, the queued ones are skipped (return code `None`), and a call that waits raises
|
|
475
|
+
`BrokenPipeError` once its commands are dead, whichever of those forms the platform gave the write (`except OSError` catches
|
|
476
|
+
it too). A pool stops all its commands, and a call on a thread of the program's own raises in that thread. Shown commands
|
|
477
|
+
nobody waits for (an `AsyncExecutor` made with `quiet=False`, `run_commands(wait_for_return=False)`; an `AsyncExecutor` is
|
|
478
|
+
quiet by default, and a quiet one is never stopped) are stopped without an error: `wait()`, `join()` and `join_threads()`
|
|
479
|
+
return, and the tasks tell (a stopped one has the kill's return code, a queued one `None`). Every call made after multiCMD
|
|
480
|
+
has found the reader gone, for the rest of the process, runs its commands unseen, and multiCMD's own stderr lines for it
|
|
481
|
+
(`Command path not found`, `Error running command`) are not printed either. So a cleanup in a `finally` (an unmount) runs
|
|
482
|
+
once an earlier shown call has raised. A call whose own first lines meet the reader quitting, or that follows only the
|
|
483
|
+
program's own write to that closed pipe, is a shown call like any other: its commands are skipped, and a call that waits raises. A cleanup that must run
|
|
484
|
+
whatever stdout does passes `quiet=True`. A quiet call never looks at stdout. One edge of the rule for calls made after the reader quit (deferred to 1.64,
|
|
485
|
+
docs/limitations.md): a shown call that starts after multiCMD has found the reader gone runs its commands unseen to their end,
|
|
486
|
+
on any thread, so a program that fans shown calls out over its own threads (a thread pool) under `prog | head` keeps running
|
|
487
|
+
as long as a remaining call's command runs (for ever, with `tail -f`); run such a fan-out as one call with `max_threads`, which stops as one. The library learns that its reader quit only from a failed write, and does not poll the pipe as `mcmd` does, so a
|
|
488
|
+
shown command that prints nothing more (`tail -f` of a log that went idle, under `prog | head -1`) runs until its next line
|
|
489
|
+
(see docs/limitations.md). Any other failed write (EIO from a terminal that hung up, ENOSPC from a full disk) loses only the
|
|
490
|
+
output: multiCMD's output is dropped from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and
|
|
491
|
+
every command runs. The program's own writes to that stdout meet the error themselves, and so does Python's flush at exit,
|
|
492
|
+
which still finds what the failed write left in `sys.stdout`'s buffer: unless the program handles that, it ends with
|
|
493
|
+
"Exception ignored" and status 120, as after a failed print of its own (a library does not redirect its caller's stdout).
|
|
494
|
+
At interpreter exit
|
|
456
495
|
the commands still running are killed, and a command queued on one of multiCMD's threads fails (-1,
|
|
457
496
|
"not started: the interpreter is exiting") instead of outliving the program; one run from an `atexit`
|
|
458
497
|
handler after that, on the main thread, runs as usual. A program that handles SIGTERM itself, or runs
|
|
@@ -460,8 +499,8 @@ multiCMD from its own threads (where Ctrl-C never arrives), can call `multiCMD.k
|
|
|
460
499
|
handler. A command not seen to exit a second after SIGKILL is no longer tracked; its pid is named on
|
|
461
500
|
stderr, unless quiet.
|
|
462
501
|
|
|
463
|
-
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers,
|
|
464
|
-
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
502
|
+
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers and ignores SIGTTIN / SIGTTOU,
|
|
503
|
+
nothing else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
465
504
|
|
|
466
505
|
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
467
506
|
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
@@ -537,6 +576,62 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
537
576
|
|
|
538
577
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
539
578
|
|
|
579
|
+
## Upgrading to 1.63 from 1.62
|
|
580
|
+
|
|
581
|
+
- Nothing needs doing to upgrade, except for three kinds of library program. One that catches `ConnectionResetError` from a
|
|
582
|
+
shown call now gets `BrokenPipeError` for a reset socket (catch `OSError` or `BrokenPipeError`). One that relied on 1.62's
|
|
583
|
+
error from every shown call made after the reader quit (a loop that catches per item, a thread pool) now has those calls
|
|
584
|
+
run unseen: see the library bullet below. One that caught `OSError` from a shown call to learn that stdout failed (a full
|
|
585
|
+
disk, a terminal that hung up) no longer gets it: the commands run, and one line on stderr says the output is dropped (1.62
|
|
586
|
+
raised the error from a serial call and ran nothing, and a pool returned -1).
|
|
587
|
+
- Fix: a write to stdout that fails for another reason than a reader quitting no longer breaks the run. With a terminal that
|
|
588
|
+
hung up on a job nobody signals (EIO: `setsid mcmd ...` or a `disown`ed job) or a full disk (ENOSPC), `mcmd`
|
|
589
|
+
drops its output from then on, runs every command (running and queued, serial and with `-m`; their output is still read,
|
|
590
|
+
so none blocks), says so in one line on stderr, if stderr can still take it (not with `> log 2>&1` on that disk: the log
|
|
591
|
+
just stops), and exits with the commands' own status, `> log 2>&1` included. 1.62 printed
|
|
592
|
+
tracebacks, did not start the queued commands, often lost the running ones (they died at their next line), and exited 120.
|
|
593
|
+
`-h`, `-V` and `-n` to a full disk end 0 with that line, where 1.62 ended 120 with "Exception ignored". A job its
|
|
594
|
+
terminal's hang-up signals (the foreground job; any job of bash or zsh) still gets SIGHUP when it hangs up, and stops
|
|
595
|
+
(`129`), as before.
|
|
596
|
+
- Fix: a stderr that cannot be written (`mcmd ... 2>/dev/full`, or a pipe nobody reads) changes no exit status: its messages
|
|
597
|
+
are dropped. 1.62 ended 120, from Python's flush at exit (`mcmd no-such-command 2>/dev/full` gave 120, not 127). On Python
|
|
598
|
+
3.9 and 3.10 a usage error then ends 1, not 2 (1.62: 120).
|
|
599
|
+
- Fix: `mcmd ... 2>&-` (stderr closed at start) puts none of its messages, and no usage error, into stdout. 1.62 wrote them
|
|
600
|
+
there (`Command path not found`, `mcmd: no commands to run`, argparse's usage), and a usage error ended 1 on Python 3.6 and
|
|
601
|
+
3.9. In a program that imports multiCMD, its warnings and failure messages are dropped then, not written to stdout.
|
|
602
|
+
- Fix: `mcmd ... >&-` (stdout closed at start) drops the output silently and runs every command. 1.62 printed "Error running
|
|
603
|
+
command" and a traceback, and a serial run did not start its commands. In a program that imports multiCMD, a `None`
|
|
604
|
+
`sys.stdout` does the same: the output is dropped and the command runs, where 1.62 raised `AttributeError`, printed "Error
|
|
605
|
+
running command" and did not run it (return code -1).
|
|
606
|
+
- Fix, Python 3.6 in a C locale (ASCII stdout): a command's non-ASCII output is shown with backslash escapes (`caf\xe9`).
|
|
607
|
+
1.62 killed the thread that read the command's output with a `UnicodeEncodeError`.
|
|
608
|
+
- Fix: a socket its peer reset (ECONNRESET) is a reader that quit, as a closed pipe is: `mcmd` stops its commands and ends
|
|
609
|
+
141 with nothing on stderr. 1.62 printed a traceback, or an "Error running command" line, for it.
|
|
610
|
+
- Changed, Windows: EINVAL from a write to stdout is a reader that quit only when stdout is a pipe. On any other stdout
|
|
611
|
+
it loses the output as above, where 1.62 stopped the commands and exited 1 (Windows' C runtime gives EINVAL for other
|
|
612
|
+
write errors too).
|
|
613
|
+
- Changed, library: a failed write of multiCMD's own output (not quiet) no longer raises in the thread that wrote, and
|
|
614
|
+
`BrokenPipeError` now means a reader that quit, in every form. A reader that quit (EPIPE, ECONNRESET, on Windows EINVAL
|
|
615
|
+
from a pipe) stops the calls that show their commands: they stop them, skip the queued ones, and a waiting
|
|
616
|
+
`run_commands()` (`run_command()` too) raises `BrokenPipeError` once they are dead. 1.62 documented "`BrokenPipeError`;
|
|
617
|
+
`OSError` EINVAL on Windows", and a reset socket gave `ConnectionResetError`: now it is one error, and `except OSError`
|
|
618
|
+
catches it as before. Shown commands nobody waits for (an `AsyncExecutor` made with `quiet=False`,
|
|
619
|
+
or `run_commands(..., wait_for_return=False)`; an `AsyncExecutor` is quiet by default, and is then never stopped) are stopped without an error.
|
|
620
|
+
Calls made after multiCMD has found the reader gone run their commands unseen, without multiCMD's own stderr lines, where
|
|
621
|
+
1.62 raised again and ran nothing (a cleanup still runs, unseen, once an earlier shown call has raised; one that must run
|
|
622
|
+
whatever stdout does passes `quiet=True`). A shown call that starts after that runs its commands unseen to their end on any
|
|
623
|
+
thread, so a fan-out over the program's own threads (a thread pool) under `prog | head` can keep running as long as a remaining
|
|
624
|
+
call's command runs, where 1.62 raised in every call: run it as one call with `max_threads`, which stops as one
|
|
625
|
+
(deferred to 1.64, docs/limitations.md). The library does not poll the pipe as `mcmd` does: a shown command that prints nothing more
|
|
626
|
+
runs until its next line (docs/limitations.md; 1.62's was the same). Any other failed write only loses the output: dropped
|
|
627
|
+
from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and every command runs. 1.62 raised the
|
|
628
|
+
error in the thread that wrote: a command whose "Running command" line could not be written counted as failed (-1) without
|
|
629
|
+
running, a reader that could not write a line died with a traceback, taking the command's output pipe with it, a pool
|
|
630
|
+
worker left a traceback, and a serial call raised the error to the caller. `print_progress_bar()` and the report of
|
|
631
|
+
`AsyncExecutor.join()` meet the same rule (1.62: `OSError` from a terminal that hung up). A program that imports
|
|
632
|
+
multiCMD meets the error in its own next write to that stdout, and in Python's flush at exit, which still finds what the
|
|
633
|
+
failed write left in `sys.stdout`'s buffer ("Exception ignored" and status 120, unless the program handles it).
|
|
634
|
+
|
|
540
635
|
## Upgrading to 1.62 from 1.61
|
|
541
636
|
|
|
542
637
|
- Nothing needs doing to upgrade, except for a run that must outlive whatever reads its stdout, such as
|
|
@@ -168,6 +168,7 @@ mcmd --shell -m 4 "dmesg | tail -n 5" "journalctl -n 5 > /tmp/j.log"
|
|
|
168
168
|
| Usage error (bad option, unbalanced quote, no commands) | `2` |
|
|
169
169
|
| Ctrl-C | `130` (`128+N` after SIGTERM / SIGHUP) |
|
|
170
170
|
| stdout has no reader (`mcmd ... \| head`) | ended by SIGPIPE, which a shell reports as `141`; `1` on Windows |
|
|
171
|
+
| stdout fails otherwise (a full disk; a terminal that hung up, on a job its hang-up does not signal) | the commands' own status, as if it had not: every command runs, and one line on stderr says the output was lost (unless stderr is the same dead target, as with `> log 2>&1` on a full disk: then the log just stops) |
|
|
171
172
|
|
|
172
173
|
### Input files and templates
|
|
173
174
|
|
|
@@ -418,15 +419,53 @@ Ctrl-C (or a SIGTERM handler's `sys.exit()`) in a call waiting on the main threa
|
|
|
418
419
|
and `AsyncExecutor.wait()` included, stops every command, skips the queued ones and
|
|
419
420
|
re-raises, giving them up to 5 s to exit; a second Ctrl-C ends that wait at once. `mcmd` stops its
|
|
420
421
|
commands on SIGTERM / SIGHUP (unless started with them ignored, as under `nohup`), and when its stdout
|
|
421
|
-
has no reader (`mcmd ... | head
|
|
422
|
-
nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
422
|
+
has no reader (`mcmd ... | head`, or a socket its peer closed or reset): it stops them as a Ctrl-C does, and ends by
|
|
423
|
+
SIGPIPE, as `yes | head` does, with nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
423
424
|
nothing more is stopped as well (`mcmd 'sleep 4' | head -2` ends at once); with any other stdout, and on Windows, it
|
|
424
|
-
learns it only when a write fails, and a command that prints nothing more runs to its end first
|
|
425
|
+
learns it only when a write fails, and a command that prints nothing more runs to its end first (on Windows that is a known
|
|
426
|
+
limitation, docs/limitations.md). ksh93 on Linux builds its
|
|
425
427
|
pipelines from sockets, so under it `mcmd ... | head` is the same: a write finds the reader gone, as in 1.61 (bash, dash, zsh,
|
|
426
|
-
mksh, busybox and macOS's ksh give a pipe). A
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
mksh, busybox and macOS's ksh give a pipe). A write to stdout that fails for any other reason (EIO from a terminal that
|
|
429
|
+
hung up, ENOSPC from a full disk; on Windows, EINVAL from anything but a pipe) loses only the output: `mcmd` drops it from
|
|
430
|
+
then on, runs every command, running and queued, says so in one line on stderr (`mcmd: cannot write to stdout ([Errno 5]
|
|
431
|
+
Input/output error): its output is dropped from here on`), if stderr can still take it, and exits with the commands' own
|
|
432
|
+
status, also with stdout and stderr on the same file. If stderr is that same dead target (`> log 2>&1` on a full disk), the
|
|
433
|
+
line is lost with the rest and the log just stops (it is written at exit if the target can take it by then). A stdout that
|
|
434
|
+
another program left non-blocking (`O_NONBLOCK`) fails with EAGAIN whenever its pipe or terminal is momentarily full, and
|
|
435
|
+
that counts as a failed write too: the output is dropped from then on. A program that imports multiCMD then never learns that
|
|
436
|
+
its reader quit: a shown `tail -f` runs on after `prog | head` has quit (`mcmd` asks the pipe, as above, and stops; see
|
|
437
|
+
docs/limitations.md). A terminal that hangs up also sends SIGHUP to the job in its foreground (a closed terminal window, or `ssh -t` whose connection drops), and bash and
|
|
438
|
+
zsh pass it on to every job they started, in the background too (dash does not): that stops the commands as before, and
|
|
439
|
+
`mcmd` ends `129`. A job nobody signals runs to its end: one that was `disown`ed, started with `setsid` or `nohup`, or, in
|
|
440
|
+
bash and dash, left in the background by `exit` (zsh signals its jobs on `exit` too). Over `ssh` without a pty, stdout is a
|
|
441
|
+
pipe to sshd, and a dropped connection closes it: a reader that quit. So a run that must outlive its terminal or its
|
|
442
|
+
connection, whatever starts it, runs under `nohup` (against the hang-up's SIGHUP) with its stdout in a file (which no
|
|
443
|
+
hang-up or dropped connection can close): `nohup mcmd -q ... > log 2>&1 &`. A program that imports multiCMD follows the same
|
|
444
|
+
rule for the writes of multiCMD's own output (its live output, `print_progress_bar()`, the report of `AsyncExecutor.join()`),
|
|
445
|
+
and none of those writes raises an `OSError` in the thread that wrote (a `sys.stdout` the program closed itself still gives
|
|
446
|
+
`ValueError`, as in 1.62: deferred to 1.64, docs/limitations.md). A reader that quit (`BrokenPipeError`, `ConnectionResetError`, or on
|
|
447
|
+
Windows `OSError` EINVAL from a pipe) stops the calls that are showing their commands (not quiet): their commands are
|
|
448
|
+
stopped as a Ctrl-C stops them, the queued ones are skipped (return code `None`), and a call that waits raises
|
|
449
|
+
`BrokenPipeError` once its commands are dead, whichever of those forms the platform gave the write (`except OSError` catches
|
|
450
|
+
it too). A pool stops all its commands, and a call on a thread of the program's own raises in that thread. Shown commands
|
|
451
|
+
nobody waits for (an `AsyncExecutor` made with `quiet=False`, `run_commands(wait_for_return=False)`; an `AsyncExecutor` is
|
|
452
|
+
quiet by default, and a quiet one is never stopped) are stopped without an error: `wait()`, `join()` and `join_threads()`
|
|
453
|
+
return, and the tasks tell (a stopped one has the kill's return code, a queued one `None`). Every call made after multiCMD
|
|
454
|
+
has found the reader gone, for the rest of the process, runs its commands unseen, and multiCMD's own stderr lines for it
|
|
455
|
+
(`Command path not found`, `Error running command`) are not printed either. So a cleanup in a `finally` (an unmount) runs
|
|
456
|
+
once an earlier shown call has raised. A call whose own first lines meet the reader quitting, or that follows only the
|
|
457
|
+
program's own write to that closed pipe, is a shown call like any other: its commands are skipped, and a call that waits raises. A cleanup that must run
|
|
458
|
+
whatever stdout does passes `quiet=True`. A quiet call never looks at stdout. One edge of the rule for calls made after the reader quit (deferred to 1.64,
|
|
459
|
+
docs/limitations.md): a shown call that starts after multiCMD has found the reader gone runs its commands unseen to their end,
|
|
460
|
+
on any thread, so a program that fans shown calls out over its own threads (a thread pool) under `prog | head` keeps running
|
|
461
|
+
as long as a remaining call's command runs (for ever, with `tail -f`); run such a fan-out as one call with `max_threads`, which stops as one. The library learns that its reader quit only from a failed write, and does not poll the pipe as `mcmd` does, so a
|
|
462
|
+
shown command that prints nothing more (`tail -f` of a log that went idle, under `prog | head -1`) runs until its next line
|
|
463
|
+
(see docs/limitations.md). Any other failed write (EIO from a terminal that hung up, ENOSPC from a full disk) loses only the
|
|
464
|
+
output: multiCMD's output is dropped from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and
|
|
465
|
+
every command runs. The program's own writes to that stdout meet the error themselves, and so does Python's flush at exit,
|
|
466
|
+
which still finds what the failed write left in `sys.stdout`'s buffer: unless the program handles that, it ends with
|
|
467
|
+
"Exception ignored" and status 120, as after a failed print of its own (a library does not redirect its caller's stdout).
|
|
468
|
+
At interpreter exit
|
|
430
469
|
the commands still running are killed, and a command queued on one of multiCMD's threads fails (-1,
|
|
431
470
|
"not started: the interpreter is exiting") instead of outliving the program; one run from an `atexit`
|
|
432
471
|
handler after that, on the main thread, runs as usual. A program that handles SIGTERM itself, or runs
|
|
@@ -434,8 +473,8 @@ multiCMD from its own threads (where Ctrl-C never arrives), can call `multiCMD.k
|
|
|
434
473
|
handler. A command not seen to exit a second after SIGKILL is no longer tracked; its pid is named on
|
|
435
474
|
stderr, unless quiet.
|
|
436
475
|
|
|
437
|
-
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers,
|
|
438
|
-
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
476
|
+
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers and ignores SIGTTIN / SIGTTOU,
|
|
477
|
+
nothing else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
439
478
|
|
|
440
479
|
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
441
480
|
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
@@ -511,6 +550,62 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
511
550
|
|
|
512
551
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
513
552
|
|
|
553
|
+
## Upgrading to 1.63 from 1.62
|
|
554
|
+
|
|
555
|
+
- Nothing needs doing to upgrade, except for three kinds of library program. One that catches `ConnectionResetError` from a
|
|
556
|
+
shown call now gets `BrokenPipeError` for a reset socket (catch `OSError` or `BrokenPipeError`). One that relied on 1.62's
|
|
557
|
+
error from every shown call made after the reader quit (a loop that catches per item, a thread pool) now has those calls
|
|
558
|
+
run unseen: see the library bullet below. One that caught `OSError` from a shown call to learn that stdout failed (a full
|
|
559
|
+
disk, a terminal that hung up) no longer gets it: the commands run, and one line on stderr says the output is dropped (1.62
|
|
560
|
+
raised the error from a serial call and ran nothing, and a pool returned -1).
|
|
561
|
+
- Fix: a write to stdout that fails for another reason than a reader quitting no longer breaks the run. With a terminal that
|
|
562
|
+
hung up on a job nobody signals (EIO: `setsid mcmd ...` or a `disown`ed job) or a full disk (ENOSPC), `mcmd`
|
|
563
|
+
drops its output from then on, runs every command (running and queued, serial and with `-m`; their output is still read,
|
|
564
|
+
so none blocks), says so in one line on stderr, if stderr can still take it (not with `> log 2>&1` on that disk: the log
|
|
565
|
+
just stops), and exits with the commands' own status, `> log 2>&1` included. 1.62 printed
|
|
566
|
+
tracebacks, did not start the queued commands, often lost the running ones (they died at their next line), and exited 120.
|
|
567
|
+
`-h`, `-V` and `-n` to a full disk end 0 with that line, where 1.62 ended 120 with "Exception ignored". A job its
|
|
568
|
+
terminal's hang-up signals (the foreground job; any job of bash or zsh) still gets SIGHUP when it hangs up, and stops
|
|
569
|
+
(`129`), as before.
|
|
570
|
+
- Fix: a stderr that cannot be written (`mcmd ... 2>/dev/full`, or a pipe nobody reads) changes no exit status: its messages
|
|
571
|
+
are dropped. 1.62 ended 120, from Python's flush at exit (`mcmd no-such-command 2>/dev/full` gave 120, not 127). On Python
|
|
572
|
+
3.9 and 3.10 a usage error then ends 1, not 2 (1.62: 120).
|
|
573
|
+
- Fix: `mcmd ... 2>&-` (stderr closed at start) puts none of its messages, and no usage error, into stdout. 1.62 wrote them
|
|
574
|
+
there (`Command path not found`, `mcmd: no commands to run`, argparse's usage), and a usage error ended 1 on Python 3.6 and
|
|
575
|
+
3.9. In a program that imports multiCMD, its warnings and failure messages are dropped then, not written to stdout.
|
|
576
|
+
- Fix: `mcmd ... >&-` (stdout closed at start) drops the output silently and runs every command. 1.62 printed "Error running
|
|
577
|
+
command" and a traceback, and a serial run did not start its commands. In a program that imports multiCMD, a `None`
|
|
578
|
+
`sys.stdout` does the same: the output is dropped and the command runs, where 1.62 raised `AttributeError`, printed "Error
|
|
579
|
+
running command" and did not run it (return code -1).
|
|
580
|
+
- Fix, Python 3.6 in a C locale (ASCII stdout): a command's non-ASCII output is shown with backslash escapes (`caf\xe9`).
|
|
581
|
+
1.62 killed the thread that read the command's output with a `UnicodeEncodeError`.
|
|
582
|
+
- Fix: a socket its peer reset (ECONNRESET) is a reader that quit, as a closed pipe is: `mcmd` stops its commands and ends
|
|
583
|
+
141 with nothing on stderr. 1.62 printed a traceback, or an "Error running command" line, for it.
|
|
584
|
+
- Changed, Windows: EINVAL from a write to stdout is a reader that quit only when stdout is a pipe. On any other stdout
|
|
585
|
+
it loses the output as above, where 1.62 stopped the commands and exited 1 (Windows' C runtime gives EINVAL for other
|
|
586
|
+
write errors too).
|
|
587
|
+
- Changed, library: a failed write of multiCMD's own output (not quiet) no longer raises in the thread that wrote, and
|
|
588
|
+
`BrokenPipeError` now means a reader that quit, in every form. A reader that quit (EPIPE, ECONNRESET, on Windows EINVAL
|
|
589
|
+
from a pipe) stops the calls that show their commands: they stop them, skip the queued ones, and a waiting
|
|
590
|
+
`run_commands()` (`run_command()` too) raises `BrokenPipeError` once they are dead. 1.62 documented "`BrokenPipeError`;
|
|
591
|
+
`OSError` EINVAL on Windows", and a reset socket gave `ConnectionResetError`: now it is one error, and `except OSError`
|
|
592
|
+
catches it as before. Shown commands nobody waits for (an `AsyncExecutor` made with `quiet=False`,
|
|
593
|
+
or `run_commands(..., wait_for_return=False)`; an `AsyncExecutor` is quiet by default, and is then never stopped) are stopped without an error.
|
|
594
|
+
Calls made after multiCMD has found the reader gone run their commands unseen, without multiCMD's own stderr lines, where
|
|
595
|
+
1.62 raised again and ran nothing (a cleanup still runs, unseen, once an earlier shown call has raised; one that must run
|
|
596
|
+
whatever stdout does passes `quiet=True`). A shown call that starts after that runs its commands unseen to their end on any
|
|
597
|
+
thread, so a fan-out over the program's own threads (a thread pool) under `prog | head` can keep running as long as a remaining
|
|
598
|
+
call's command runs, where 1.62 raised in every call: run it as one call with `max_threads`, which stops as one
|
|
599
|
+
(deferred to 1.64, docs/limitations.md). The library does not poll the pipe as `mcmd` does: a shown command that prints nothing more
|
|
600
|
+
runs until its next line (docs/limitations.md; 1.62's was the same). Any other failed write only loses the output: dropped
|
|
601
|
+
from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and every command runs. 1.62 raised the
|
|
602
|
+
error in the thread that wrote: a command whose "Running command" line could not be written counted as failed (-1) without
|
|
603
|
+
running, a reader that could not write a line died with a traceback, taking the command's output pipe with it, a pool
|
|
604
|
+
worker left a traceback, and a serial call raised the error to the caller. `print_progress_bar()` and the report of
|
|
605
|
+
`AsyncExecutor.join()` meet the same rule (1.62: `OSError` from a terminal that hung up). A program that imports
|
|
606
|
+
multiCMD meets the error in its own next write to that stdout, and in Python's flush at exit, which still finds what the
|
|
607
|
+
failed write left in `sys.stdout`'s buffer ("Exception ignored" and status 120, unless the program handles it).
|
|
608
|
+
|
|
514
609
|
## Upgrading to 1.62 from 1.61
|
|
515
610
|
|
|
516
611
|
- Nothing needs doing to upgrade, except for a run that must outlive whatever reads its stdout, such as
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.63
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -194,6 +194,7 @@ mcmd --shell -m 4 "dmesg | tail -n 5" "journalctl -n 5 > /tmp/j.log"
|
|
|
194
194
|
| Usage error (bad option, unbalanced quote, no commands) | `2` |
|
|
195
195
|
| Ctrl-C | `130` (`128+N` after SIGTERM / SIGHUP) |
|
|
196
196
|
| stdout has no reader (`mcmd ... \| head`) | ended by SIGPIPE, which a shell reports as `141`; `1` on Windows |
|
|
197
|
+
| stdout fails otherwise (a full disk; a terminal that hung up, on a job its hang-up does not signal) | the commands' own status, as if it had not: every command runs, and one line on stderr says the output was lost (unless stderr is the same dead target, as with `> log 2>&1` on a full disk: then the log just stops) |
|
|
197
198
|
|
|
198
199
|
### Input files and templates
|
|
199
200
|
|
|
@@ -444,15 +445,53 @@ Ctrl-C (or a SIGTERM handler's `sys.exit()`) in a call waiting on the main threa
|
|
|
444
445
|
and `AsyncExecutor.wait()` included, stops every command, skips the queued ones and
|
|
445
446
|
re-raises, giving them up to 5 s to exit; a second Ctrl-C ends that wait at once. `mcmd` stops its
|
|
446
447
|
commands on SIGTERM / SIGHUP (unless started with them ignored, as under `nohup`), and when its stdout
|
|
447
|
-
has no reader (`mcmd ... | head
|
|
448
|
-
nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
448
|
+
has no reader (`mcmd ... | head`, or a socket its peer closed or reset): it stops them as a Ctrl-C does, and ends by
|
|
449
|
+
SIGPIPE, as `yes | head` does, with nothing on stderr. When stdout is a pipe on Linux and macOS it also asks the pipe as it waits, so a command that prints
|
|
449
450
|
nothing more is stopped as well (`mcmd 'sleep 4' | head -2` ends at once); with any other stdout, and on Windows, it
|
|
450
|
-
learns it only when a write fails, and a command that prints nothing more runs to its end first
|
|
451
|
+
learns it only when a write fails, and a command that prints nothing more runs to its end first (on Windows that is a known
|
|
452
|
+
limitation, docs/limitations.md). ksh93 on Linux builds its
|
|
451
453
|
pipelines from sockets, so under it `mcmd ... | head` is the same: a write finds the reader gone, as in 1.61 (bash, dash, zsh,
|
|
452
|
-
mksh, busybox and macOS's ksh give a pipe). A
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
mksh, busybox and macOS's ksh give a pipe). A write to stdout that fails for any other reason (EIO from a terminal that
|
|
455
|
+
hung up, ENOSPC from a full disk; on Windows, EINVAL from anything but a pipe) loses only the output: `mcmd` drops it from
|
|
456
|
+
then on, runs every command, running and queued, says so in one line on stderr (`mcmd: cannot write to stdout ([Errno 5]
|
|
457
|
+
Input/output error): its output is dropped from here on`), if stderr can still take it, and exits with the commands' own
|
|
458
|
+
status, also with stdout and stderr on the same file. If stderr is that same dead target (`> log 2>&1` on a full disk), the
|
|
459
|
+
line is lost with the rest and the log just stops (it is written at exit if the target can take it by then). A stdout that
|
|
460
|
+
another program left non-blocking (`O_NONBLOCK`) fails with EAGAIN whenever its pipe or terminal is momentarily full, and
|
|
461
|
+
that counts as a failed write too: the output is dropped from then on. A program that imports multiCMD then never learns that
|
|
462
|
+
its reader quit: a shown `tail -f` runs on after `prog | head` has quit (`mcmd` asks the pipe, as above, and stops; see
|
|
463
|
+
docs/limitations.md). A terminal that hangs up also sends SIGHUP to the job in its foreground (a closed terminal window, or `ssh -t` whose connection drops), and bash and
|
|
464
|
+
zsh pass it on to every job they started, in the background too (dash does not): that stops the commands as before, and
|
|
465
|
+
`mcmd` ends `129`. A job nobody signals runs to its end: one that was `disown`ed, started with `setsid` or `nohup`, or, in
|
|
466
|
+
bash and dash, left in the background by `exit` (zsh signals its jobs on `exit` too). Over `ssh` without a pty, stdout is a
|
|
467
|
+
pipe to sshd, and a dropped connection closes it: a reader that quit. So a run that must outlive its terminal or its
|
|
468
|
+
connection, whatever starts it, runs under `nohup` (against the hang-up's SIGHUP) with its stdout in a file (which no
|
|
469
|
+
hang-up or dropped connection can close): `nohup mcmd -q ... > log 2>&1 &`. A program that imports multiCMD follows the same
|
|
470
|
+
rule for the writes of multiCMD's own output (its live output, `print_progress_bar()`, the report of `AsyncExecutor.join()`),
|
|
471
|
+
and none of those writes raises an `OSError` in the thread that wrote (a `sys.stdout` the program closed itself still gives
|
|
472
|
+
`ValueError`, as in 1.62: deferred to 1.64, docs/limitations.md). A reader that quit (`BrokenPipeError`, `ConnectionResetError`, or on
|
|
473
|
+
Windows `OSError` EINVAL from a pipe) stops the calls that are showing their commands (not quiet): their commands are
|
|
474
|
+
stopped as a Ctrl-C stops them, the queued ones are skipped (return code `None`), and a call that waits raises
|
|
475
|
+
`BrokenPipeError` once its commands are dead, whichever of those forms the platform gave the write (`except OSError` catches
|
|
476
|
+
it too). A pool stops all its commands, and a call on a thread of the program's own raises in that thread. Shown commands
|
|
477
|
+
nobody waits for (an `AsyncExecutor` made with `quiet=False`, `run_commands(wait_for_return=False)`; an `AsyncExecutor` is
|
|
478
|
+
quiet by default, and a quiet one is never stopped) are stopped without an error: `wait()`, `join()` and `join_threads()`
|
|
479
|
+
return, and the tasks tell (a stopped one has the kill's return code, a queued one `None`). Every call made after multiCMD
|
|
480
|
+
has found the reader gone, for the rest of the process, runs its commands unseen, and multiCMD's own stderr lines for it
|
|
481
|
+
(`Command path not found`, `Error running command`) are not printed either. So a cleanup in a `finally` (an unmount) runs
|
|
482
|
+
once an earlier shown call has raised. A call whose own first lines meet the reader quitting, or that follows only the
|
|
483
|
+
program's own write to that closed pipe, is a shown call like any other: its commands are skipped, and a call that waits raises. A cleanup that must run
|
|
484
|
+
whatever stdout does passes `quiet=True`. A quiet call never looks at stdout. One edge of the rule for calls made after the reader quit (deferred to 1.64,
|
|
485
|
+
docs/limitations.md): a shown call that starts after multiCMD has found the reader gone runs its commands unseen to their end,
|
|
486
|
+
on any thread, so a program that fans shown calls out over its own threads (a thread pool) under `prog | head` keeps running
|
|
487
|
+
as long as a remaining call's command runs (for ever, with `tail -f`); run such a fan-out as one call with `max_threads`, which stops as one. The library learns that its reader quit only from a failed write, and does not poll the pipe as `mcmd` does, so a
|
|
488
|
+
shown command that prints nothing more (`tail -f` of a log that went idle, under `prog | head -1`) runs until its next line
|
|
489
|
+
(see docs/limitations.md). Any other failed write (EIO from a terminal that hung up, ENOSPC from a full disk) loses only the
|
|
490
|
+
output: multiCMD's output is dropped from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and
|
|
491
|
+
every command runs. The program's own writes to that stdout meet the error themselves, and so does Python's flush at exit,
|
|
492
|
+
which still finds what the failed write left in `sys.stdout`'s buffer: unless the program handles that, it ends with
|
|
493
|
+
"Exception ignored" and status 120, as after a failed print of its own (a library does not redirect its caller's stdout).
|
|
494
|
+
At interpreter exit
|
|
456
495
|
the commands still running are killed, and a command queued on one of multiCMD's threads fails (-1,
|
|
457
496
|
"not started: the interpreter is exiting") instead of outliving the program; one run from an `atexit`
|
|
458
497
|
handler after that, on the main thread, runs as usual. A program that handles SIGTERM itself, or runs
|
|
@@ -460,8 +499,8 @@ multiCMD from its own threads (where Ctrl-C never arrives), can call `multiCMD.k
|
|
|
460
499
|
handler. A command not seen to exit a second after SIGKILL is no longer tracked; its pid is named on
|
|
461
500
|
stderr, unless quiet.
|
|
462
501
|
|
|
463
|
-
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers,
|
|
464
|
-
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
502
|
+
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers and ignores SIGTTIN / SIGTTOU,
|
|
503
|
+
nothing else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
465
504
|
|
|
466
505
|
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
467
506
|
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
@@ -537,6 +576,62 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
537
576
|
|
|
538
577
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
539
578
|
|
|
579
|
+
## Upgrading to 1.63 from 1.62
|
|
580
|
+
|
|
581
|
+
- Nothing needs doing to upgrade, except for three kinds of library program. One that catches `ConnectionResetError` from a
|
|
582
|
+
shown call now gets `BrokenPipeError` for a reset socket (catch `OSError` or `BrokenPipeError`). One that relied on 1.62's
|
|
583
|
+
error from every shown call made after the reader quit (a loop that catches per item, a thread pool) now has those calls
|
|
584
|
+
run unseen: see the library bullet below. One that caught `OSError` from a shown call to learn that stdout failed (a full
|
|
585
|
+
disk, a terminal that hung up) no longer gets it: the commands run, and one line on stderr says the output is dropped (1.62
|
|
586
|
+
raised the error from a serial call and ran nothing, and a pool returned -1).
|
|
587
|
+
- Fix: a write to stdout that fails for another reason than a reader quitting no longer breaks the run. With a terminal that
|
|
588
|
+
hung up on a job nobody signals (EIO: `setsid mcmd ...` or a `disown`ed job) or a full disk (ENOSPC), `mcmd`
|
|
589
|
+
drops its output from then on, runs every command (running and queued, serial and with `-m`; their output is still read,
|
|
590
|
+
so none blocks), says so in one line on stderr, if stderr can still take it (not with `> log 2>&1` on that disk: the log
|
|
591
|
+
just stops), and exits with the commands' own status, `> log 2>&1` included. 1.62 printed
|
|
592
|
+
tracebacks, did not start the queued commands, often lost the running ones (they died at their next line), and exited 120.
|
|
593
|
+
`-h`, `-V` and `-n` to a full disk end 0 with that line, where 1.62 ended 120 with "Exception ignored". A job its
|
|
594
|
+
terminal's hang-up signals (the foreground job; any job of bash or zsh) still gets SIGHUP when it hangs up, and stops
|
|
595
|
+
(`129`), as before.
|
|
596
|
+
- Fix: a stderr that cannot be written (`mcmd ... 2>/dev/full`, or a pipe nobody reads) changes no exit status: its messages
|
|
597
|
+
are dropped. 1.62 ended 120, from Python's flush at exit (`mcmd no-such-command 2>/dev/full` gave 120, not 127). On Python
|
|
598
|
+
3.9 and 3.10 a usage error then ends 1, not 2 (1.62: 120).
|
|
599
|
+
- Fix: `mcmd ... 2>&-` (stderr closed at start) puts none of its messages, and no usage error, into stdout. 1.62 wrote them
|
|
600
|
+
there (`Command path not found`, `mcmd: no commands to run`, argparse's usage), and a usage error ended 1 on Python 3.6 and
|
|
601
|
+
3.9. In a program that imports multiCMD, its warnings and failure messages are dropped then, not written to stdout.
|
|
602
|
+
- Fix: `mcmd ... >&-` (stdout closed at start) drops the output silently and runs every command. 1.62 printed "Error running
|
|
603
|
+
command" and a traceback, and a serial run did not start its commands. In a program that imports multiCMD, a `None`
|
|
604
|
+
`sys.stdout` does the same: the output is dropped and the command runs, where 1.62 raised `AttributeError`, printed "Error
|
|
605
|
+
running command" and did not run it (return code -1).
|
|
606
|
+
- Fix, Python 3.6 in a C locale (ASCII stdout): a command's non-ASCII output is shown with backslash escapes (`caf\xe9`).
|
|
607
|
+
1.62 killed the thread that read the command's output with a `UnicodeEncodeError`.
|
|
608
|
+
- Fix: a socket its peer reset (ECONNRESET) is a reader that quit, as a closed pipe is: `mcmd` stops its commands and ends
|
|
609
|
+
141 with nothing on stderr. 1.62 printed a traceback, or an "Error running command" line, for it.
|
|
610
|
+
- Changed, Windows: EINVAL from a write to stdout is a reader that quit only when stdout is a pipe. On any other stdout
|
|
611
|
+
it loses the output as above, where 1.62 stopped the commands and exited 1 (Windows' C runtime gives EINVAL for other
|
|
612
|
+
write errors too).
|
|
613
|
+
- Changed, library: a failed write of multiCMD's own output (not quiet) no longer raises in the thread that wrote, and
|
|
614
|
+
`BrokenPipeError` now means a reader that quit, in every form. A reader that quit (EPIPE, ECONNRESET, on Windows EINVAL
|
|
615
|
+
from a pipe) stops the calls that show their commands: they stop them, skip the queued ones, and a waiting
|
|
616
|
+
`run_commands()` (`run_command()` too) raises `BrokenPipeError` once they are dead. 1.62 documented "`BrokenPipeError`;
|
|
617
|
+
`OSError` EINVAL on Windows", and a reset socket gave `ConnectionResetError`: now it is one error, and `except OSError`
|
|
618
|
+
catches it as before. Shown commands nobody waits for (an `AsyncExecutor` made with `quiet=False`,
|
|
619
|
+
or `run_commands(..., wait_for_return=False)`; an `AsyncExecutor` is quiet by default, and is then never stopped) are stopped without an error.
|
|
620
|
+
Calls made after multiCMD has found the reader gone run their commands unseen, without multiCMD's own stderr lines, where
|
|
621
|
+
1.62 raised again and ran nothing (a cleanup still runs, unseen, once an earlier shown call has raised; one that must run
|
|
622
|
+
whatever stdout does passes `quiet=True`). A shown call that starts after that runs its commands unseen to their end on any
|
|
623
|
+
thread, so a fan-out over the program's own threads (a thread pool) under `prog | head` can keep running as long as a remaining
|
|
624
|
+
call's command runs, where 1.62 raised in every call: run it as one call with `max_threads`, which stops as one
|
|
625
|
+
(deferred to 1.64, docs/limitations.md). The library does not poll the pipe as `mcmd` does: a shown command that prints nothing more
|
|
626
|
+
runs until its next line (docs/limitations.md; 1.62's was the same). Any other failed write only loses the output: dropped
|
|
627
|
+
from then on, one line on stderr says so (`multiCMD: cannot write to stdout ...`), and every command runs. 1.62 raised the
|
|
628
|
+
error in the thread that wrote: a command whose "Running command" line could not be written counted as failed (-1) without
|
|
629
|
+
running, a reader that could not write a line died with a traceback, taking the command's output pipe with it, a pool
|
|
630
|
+
worker left a traceback, and a serial call raised the error to the caller. `print_progress_bar()` and the report of
|
|
631
|
+
`AsyncExecutor.join()` meet the same rule (1.62: `OSError` from a terminal that hung up). A program that imports
|
|
632
|
+
multiCMD meets the error in its own next write to that stdout, and in Python's flush at exit, which still finds what the
|
|
633
|
+
failed write left in `sys.stdout`'s buffer ("Exception ignored" and status 120, unless the program handles it).
|
|
634
|
+
|
|
540
635
|
## Upgrading to 1.62 from 1.61
|
|
541
636
|
|
|
542
637
|
- Nothing needs doing to upgrade, except for a run that must outlive whatever reads its stdout, such as
|
|
@@ -12,6 +12,7 @@ tests/test_api.py
|
|
|
12
12
|
tests/test_async_executor.py
|
|
13
13
|
tests/test_cli.py
|
|
14
14
|
tests/test_cli_closed_stdout.py
|
|
15
|
+
tests/test_cli_failed_stdout.py
|
|
15
16
|
tests/test_cli_input.py
|
|
16
17
|
tests/test_cli_summary.py
|
|
17
18
|
tests/test_display.py
|
|
@@ -29,6 +30,7 @@ tests/test_pool.py
|
|
|
29
30
|
tests/test_process_groups.py
|
|
30
31
|
tests/test_pty.py
|
|
31
32
|
tests/test_reader.py
|
|
33
|
+
tests/test_reader_quit.py
|
|
32
34
|
tests/test_regressions.py
|
|
33
35
|
tests/test_run_command.py
|
|
34
36
|
tests/test_run_commands.py
|