multiCMD 1.72__tar.gz → 1.75__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.72 → multicmd-1.75}/PKG-INFO +75 -11
- {multicmd-1.72 → multicmd-1.75}/README.md +74 -10
- {multicmd-1.72 → multicmd-1.75}/multiCMD.egg-info/PKG-INFO +75 -11
- {multicmd-1.72 → multicmd-1.75}/multiCMD.py +247 -148
- multicmd-1.75/tests/test_async_executor.py +1720 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_env.py +2 -4
- {multicmd-1.72 → multicmd-1.75}/tests/test_interrupts.py +10 -10
- {multicmd-1.72 → multicmd-1.75}/tests/test_pass_fds.py +24 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_process_groups.py +4 -4
- {multicmd-1.72 → multicmd-1.75}/tests/test_reader.py +1 -1
- {multicmd-1.72 → multicmd-1.75}/tests/test_run_commands.py +38 -1
- {multicmd-1.72 → multicmd-1.75}/tests/test_sudo.py +9 -3
- {multicmd-1.72 → multicmd-1.75}/tests/test_supervision.py +5 -5
- multicmd-1.72/tests/test_async_executor.py +0 -864
- {multicmd-1.72 → multicmd-1.75}/LICENSE +0 -0
- {multicmd-1.72 → multicmd-1.75}/multiCMD.egg-info/SOURCES.txt +0 -0
- {multicmd-1.72 → multicmd-1.75}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.72 → multicmd-1.75}/multiCMD.egg-info/entry_points.txt +0 -0
- {multicmd-1.72 → multicmd-1.75}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.72 → multicmd-1.75}/scripts/multiCMD +0 -0
- {multicmd-1.72 → multicmd-1.75}/setup.cfg +0 -0
- {multicmd-1.72 → multicmd-1.75}/setup.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_api.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_cli.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_cli_closed_stdout.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_cli_failed_stdout.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_cli_input.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_cli_summary.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_display.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_embed.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_expand_ranges.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_handover.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_helpers.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_packaging.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_parsing.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_ping.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_pool.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_pty.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_reader_quit.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_regressions.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_run_command.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_task.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/tests/test_terminal_width.py +0 -0
- {multicmd-1.72 → multicmd-1.75}/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.75
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -350,9 +350,10 @@ multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # c
|
|
|
350
350
|
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
351
351
|
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
352
352
|
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
353
|
-
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so are 0 to 2
|
|
354
|
+
(the command's own stdin, stdout and stderr) and any off POSIX. multiCMD neither closes nor
|
|
355
|
+
duplicates them, so keep them open until the command has started ( with `wait_for_return=False`
|
|
356
|
+
or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
356
357
|
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
357
358
|
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
358
359
|
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
@@ -402,13 +403,24 @@ print(ex.get_results())
|
|
|
402
403
|
|
|
403
404
|
`run_command(s)` returns right away and queues the commands. `wait()`, `join()` and
|
|
404
405
|
`stop()` wait until everything is done by default; a `timeout=` is one overall limit in
|
|
405
|
-
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
406
|
+
seconds (the constructor's `timeout` is only the per-command inactivity timeout). A
|
|
407
|
+
`wait(timeout=0)` polled in a loop can return `[]` before the last commands of its call have finished (to be fixed in
|
|
408
|
+
1.76, [docs/limitations.md](docs/limitations.md)).
|
|
406
409
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
407
410
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
408
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
409
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
410
|
-
commands are queued.
|
|
411
|
-
|
|
411
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
412
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
413
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
414
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
415
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
416
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
417
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
418
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
419
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
420
|
+
constructor that makes the semaphore.
|
|
421
|
+
A command's `task.thread`
|
|
422
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
423
|
+
executor has joined its thread, so a
|
|
412
424
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
413
425
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
414
426
|
`run_command(s)`, for that call's commands.
|
|
@@ -494,6 +506,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
|
|
|
494
506
|
Ctrl-C that arrives as a command starts waits for the exec wrapper's `Popen`, normally about 1 ms (2-5 ms at p99); if the
|
|
495
507
|
exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
|
|
496
508
|
answers.
|
|
509
|
+
For programs that use `AsyncExecutor` (no cas tool does): a `wait()` on another thread can return before a command
|
|
510
|
+
another thread's `run_commands()` is still starting; a signal handler that calls the executor while its own thread is inside
|
|
511
|
+
it waits for good; a call's commands can wait behind an earlier call's command whose own semaphore is busy; and an executor
|
|
512
|
+
busy at a `fork()` runs nothing in the child.
|
|
497
513
|
These and the other known limits are in [docs/limitations.md](docs/limitations.md).
|
|
498
514
|
|
|
499
515
|
## When stdout fails
|
|
@@ -578,6 +594,54 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
578
594
|
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
579
595
|
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
580
596
|
|
|
597
|
+
## Upgrading to 1.75 from 1.73
|
|
598
|
+
|
|
599
|
+
1.74 was not released: its changes are here.
|
|
600
|
+
|
|
601
|
+
- Nothing needs doing unless a program passes the module-level `run_command(s)` a `max_threads` that is a float above 1
|
|
602
|
+
that is not whole (`1.5`, `2.5`) or `nan`, which now raises `TypeError` in every mode, or passes 0, 1 or 2 in `pass_fds`,
|
|
603
|
+
or, after a `cleanup(timeout)` that timed out, calls `wait()` and relied on it returning at once, or reads
|
|
604
|
+
`runningThreads` and relied on it being empty.
|
|
605
|
+
- Fix: the module-level `run_command(s)` reads `max_threads` as `AsyncExecutor` does, before anything runs (`sudo -v`
|
|
606
|
+
included), whatever the number of commands and with `wait_for_return=False` too: `1.5`, `2.5`, `nan`, `None` or a
|
|
607
|
+
string raise `TypeError`, `2.0` counts as 2, and below 1 or `inf` run all at once. 1.73 raised `TypeError` for a float
|
|
608
|
+
above 1 (`2.0` too) only when it waited and had at least as many commands as the float, and otherwise ran them (`1.5`
|
|
609
|
+
all at once with `wait_for_return=False`).
|
|
610
|
+
- Changed: `pass_fds` refuses 0, 1 and 2 with a `ValueError` naming the number. The command's own stdin, stdout and
|
|
611
|
+
stderr take those numbers in the child, so a descriptor passed there was silently replaced.
|
|
612
|
+
- Changed, `AsyncExecutor`: a call held at its own `max_threads` waits, and `wait()` and `runningThreads` count it until
|
|
613
|
+
its last command has started. A command its limit held back starts ahead of the calls queued after it once
|
|
614
|
+
its slot frees (1.73: behind them). A thread that did not end within `cleanup(timeout)` stays in `wait()` and
|
|
615
|
+
`runningThreads` until it does (1.73 forgot it).
|
|
616
|
+
- Fix, `AsyncExecutor`: a dispatcher start that fails or is interrupted fails only its own call, which raises with its
|
|
617
|
+
commands skipped; they stay queued until the next call or `cleanup()`. 1.73 failed every other queued command with
|
|
618
|
+
`cannot start its thread`. A signal handler may call `cleanup()` while `run_commands()` starts the dispatcher (1.73
|
|
619
|
+
deadlocked).
|
|
620
|
+
- Fix: a Ctrl-C while multiCMD joins a finished thread leaves it to the next call, which joins and forgets it. 1.73 could
|
|
621
|
+
keep such a thread, with its command's output, until the executor ended, or for good if it ran a fire-and-forget command.
|
|
622
|
+
- Fix: in a child forked while commands ran, `AsyncExecutor.runningThreads` and `join_threads()` hold none of the
|
|
623
|
+
parent's threads. 1.73 listed the executor's, so a child that waited for `runningThreads` to be empty never ended.
|
|
624
|
+
|
|
625
|
+
## Upgrading to 1.73 from 1.72
|
|
626
|
+
|
|
627
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
628
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
629
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
630
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
631
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
632
|
+
negative value raised `ValueError`).
|
|
633
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
634
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
635
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
636
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
637
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
638
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
639
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
640
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
641
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
642
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
643
|
+
semaphore).
|
|
644
|
+
|
|
581
645
|
## Upgrading to 1.72 from 1.71
|
|
582
646
|
|
|
583
647
|
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
@@ -592,8 +656,8 @@ prints a table of what each version of `multiCMD.py` given to it did (`python3 s
|
|
|
592
656
|
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
593
657
|
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
594
658
|
ignored its exit).
|
|
595
|
-
- Known,
|
|
596
|
-
|
|
659
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
660
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
597
661
|
|
|
598
662
|
## Upgrading to 1.71 from 1.70
|
|
599
663
|
|
|
@@ -325,9 +325,10 @@ multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # c
|
|
|
325
325
|
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
326
326
|
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
327
327
|
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
328
|
-
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so are 0 to 2
|
|
329
|
+
(the command's own stdin, stdout and stderr) and any off POSIX. multiCMD neither closes nor
|
|
330
|
+
duplicates them, so keep them open until the command has started ( with `wait_for_return=False`
|
|
331
|
+
or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
331
332
|
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
332
333
|
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
333
334
|
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
@@ -377,13 +378,24 @@ print(ex.get_results())
|
|
|
377
378
|
|
|
378
379
|
`run_command(s)` returns right away and queues the commands. `wait()`, `join()` and
|
|
379
380
|
`stop()` wait until everything is done by default; a `timeout=` is one overall limit in
|
|
380
|
-
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
381
|
+
seconds (the constructor's `timeout` is only the per-command inactivity timeout). A
|
|
382
|
+
`wait(timeout=0)` polled in a loop can return `[]` before the last commands of its call have finished (to be fixed in
|
|
383
|
+
1.76, [docs/limitations.md](docs/limitations.md)).
|
|
381
384
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
382
385
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
383
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
384
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
385
|
-
commands are queued.
|
|
386
|
-
|
|
386
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
387
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
388
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
389
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
390
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
391
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
392
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
393
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
394
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
395
|
+
constructor that makes the semaphore.
|
|
396
|
+
A command's `task.thread`
|
|
397
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
398
|
+
executor has joined its thread, so a
|
|
387
399
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
388
400
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
389
401
|
`run_command(s)`, for that call's commands.
|
|
@@ -469,6 +481,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
|
|
|
469
481
|
Ctrl-C that arrives as a command starts waits for the exec wrapper's `Popen`, normally about 1 ms (2-5 ms at p99); if the
|
|
470
482
|
exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
|
|
471
483
|
answers.
|
|
484
|
+
For programs that use `AsyncExecutor` (no cas tool does): a `wait()` on another thread can return before a command
|
|
485
|
+
another thread's `run_commands()` is still starting; a signal handler that calls the executor while its own thread is inside
|
|
486
|
+
it waits for good; a call's commands can wait behind an earlier call's command whose own semaphore is busy; and an executor
|
|
487
|
+
busy at a `fork()` runs nothing in the child.
|
|
472
488
|
These and the other known limits are in [docs/limitations.md](docs/limitations.md).
|
|
473
489
|
|
|
474
490
|
## When stdout fails
|
|
@@ -553,6 +569,54 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
553
569
|
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
554
570
|
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
555
571
|
|
|
572
|
+
## Upgrading to 1.75 from 1.73
|
|
573
|
+
|
|
574
|
+
1.74 was not released: its changes are here.
|
|
575
|
+
|
|
576
|
+
- Nothing needs doing unless a program passes the module-level `run_command(s)` a `max_threads` that is a float above 1
|
|
577
|
+
that is not whole (`1.5`, `2.5`) or `nan`, which now raises `TypeError` in every mode, or passes 0, 1 or 2 in `pass_fds`,
|
|
578
|
+
or, after a `cleanup(timeout)` that timed out, calls `wait()` and relied on it returning at once, or reads
|
|
579
|
+
`runningThreads` and relied on it being empty.
|
|
580
|
+
- Fix: the module-level `run_command(s)` reads `max_threads` as `AsyncExecutor` does, before anything runs (`sudo -v`
|
|
581
|
+
included), whatever the number of commands and with `wait_for_return=False` too: `1.5`, `2.5`, `nan`, `None` or a
|
|
582
|
+
string raise `TypeError`, `2.0` counts as 2, and below 1 or `inf` run all at once. 1.73 raised `TypeError` for a float
|
|
583
|
+
above 1 (`2.0` too) only when it waited and had at least as many commands as the float, and otherwise ran them (`1.5`
|
|
584
|
+
all at once with `wait_for_return=False`).
|
|
585
|
+
- Changed: `pass_fds` refuses 0, 1 and 2 with a `ValueError` naming the number. The command's own stdin, stdout and
|
|
586
|
+
stderr take those numbers in the child, so a descriptor passed there was silently replaced.
|
|
587
|
+
- Changed, `AsyncExecutor`: a call held at its own `max_threads` waits, and `wait()` and `runningThreads` count it until
|
|
588
|
+
its last command has started. A command its limit held back starts ahead of the calls queued after it once
|
|
589
|
+
its slot frees (1.73: behind them). A thread that did not end within `cleanup(timeout)` stays in `wait()` and
|
|
590
|
+
`runningThreads` until it does (1.73 forgot it).
|
|
591
|
+
- Fix, `AsyncExecutor`: a dispatcher start that fails or is interrupted fails only its own call, which raises with its
|
|
592
|
+
commands skipped; they stay queued until the next call or `cleanup()`. 1.73 failed every other queued command with
|
|
593
|
+
`cannot start its thread`. A signal handler may call `cleanup()` while `run_commands()` starts the dispatcher (1.73
|
|
594
|
+
deadlocked).
|
|
595
|
+
- Fix: a Ctrl-C while multiCMD joins a finished thread leaves it to the next call, which joins and forgets it. 1.73 could
|
|
596
|
+
keep such a thread, with its command's output, until the executor ended, or for good if it ran a fire-and-forget command.
|
|
597
|
+
- Fix: in a child forked while commands ran, `AsyncExecutor.runningThreads` and `join_threads()` hold none of the
|
|
598
|
+
parent's threads. 1.73 listed the executor's, so a child that waited for `runningThreads` to be empty never ended.
|
|
599
|
+
|
|
600
|
+
## Upgrading to 1.73 from 1.72
|
|
601
|
+
|
|
602
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
603
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
604
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
605
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
606
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
607
|
+
negative value raised `ValueError`).
|
|
608
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
609
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
610
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
611
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
612
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
613
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
614
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
615
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
616
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
617
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
618
|
+
semaphore).
|
|
619
|
+
|
|
556
620
|
## Upgrading to 1.72 from 1.71
|
|
557
621
|
|
|
558
622
|
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
@@ -567,8 +631,8 @@ prints a table of what each version of `multiCMD.py` given to it did (`python3 s
|
|
|
567
631
|
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
568
632
|
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
569
633
|
ignored its exit).
|
|
570
|
-
- Known,
|
|
571
|
-
|
|
634
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
635
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
572
636
|
|
|
573
637
|
## Upgrading to 1.71 from 1.70
|
|
574
638
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.75
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -350,9 +350,10 @@ multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # c
|
|
|
350
350
|
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
351
351
|
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
352
352
|
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
353
|
-
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so are 0 to 2
|
|
354
|
+
(the command's own stdin, stdout and stderr) and any off POSIX. multiCMD neither closes nor
|
|
355
|
+
duplicates them, so keep them open until the command has started ( with `wait_for_return=False`
|
|
356
|
+
or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
356
357
|
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
357
358
|
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
358
359
|
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
@@ -402,13 +403,24 @@ print(ex.get_results())
|
|
|
402
403
|
|
|
403
404
|
`run_command(s)` returns right away and queues the commands. `wait()`, `join()` and
|
|
404
405
|
`stop()` wait until everything is done by default; a `timeout=` is one overall limit in
|
|
405
|
-
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
406
|
+
seconds (the constructor's `timeout` is only the per-command inactivity timeout). A
|
|
407
|
+
`wait(timeout=0)` polled in a loop can return `[]` before the last commands of its call have finished (to be fixed in
|
|
408
|
+
1.76, [docs/limitations.md](docs/limitations.md)).
|
|
406
409
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
407
410
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
408
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
409
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
410
|
-
commands are queued.
|
|
411
|
-
|
|
411
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
412
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
413
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
414
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
415
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
416
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
417
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
418
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
419
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
420
|
+
constructor that makes the semaphore.
|
|
421
|
+
A command's `task.thread`
|
|
422
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
423
|
+
executor has joined its thread, so a
|
|
412
424
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
413
425
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
414
426
|
`run_command(s)`, for that call's commands.
|
|
@@ -494,6 +506,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
|
|
|
494
506
|
Ctrl-C that arrives as a command starts waits for the exec wrapper's `Popen`, normally about 1 ms (2-5 ms at p99); if the
|
|
495
507
|
exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
|
|
496
508
|
answers.
|
|
509
|
+
For programs that use `AsyncExecutor` (no cas tool does): a `wait()` on another thread can return before a command
|
|
510
|
+
another thread's `run_commands()` is still starting; a signal handler that calls the executor while its own thread is inside
|
|
511
|
+
it waits for good; a call's commands can wait behind an earlier call's command whose own semaphore is busy; and an executor
|
|
512
|
+
busy at a `fork()` runs nothing in the child.
|
|
497
513
|
These and the other known limits are in [docs/limitations.md](docs/limitations.md).
|
|
498
514
|
|
|
499
515
|
## When stdout fails
|
|
@@ -578,6 +594,54 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
578
594
|
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
579
595
|
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
580
596
|
|
|
597
|
+
## Upgrading to 1.75 from 1.73
|
|
598
|
+
|
|
599
|
+
1.74 was not released: its changes are here.
|
|
600
|
+
|
|
601
|
+
- Nothing needs doing unless a program passes the module-level `run_command(s)` a `max_threads` that is a float above 1
|
|
602
|
+
that is not whole (`1.5`, `2.5`) or `nan`, which now raises `TypeError` in every mode, or passes 0, 1 or 2 in `pass_fds`,
|
|
603
|
+
or, after a `cleanup(timeout)` that timed out, calls `wait()` and relied on it returning at once, or reads
|
|
604
|
+
`runningThreads` and relied on it being empty.
|
|
605
|
+
- Fix: the module-level `run_command(s)` reads `max_threads` as `AsyncExecutor` does, before anything runs (`sudo -v`
|
|
606
|
+
included), whatever the number of commands and with `wait_for_return=False` too: `1.5`, `2.5`, `nan`, `None` or a
|
|
607
|
+
string raise `TypeError`, `2.0` counts as 2, and below 1 or `inf` run all at once. 1.73 raised `TypeError` for a float
|
|
608
|
+
above 1 (`2.0` too) only when it waited and had at least as many commands as the float, and otherwise ran them (`1.5`
|
|
609
|
+
all at once with `wait_for_return=False`).
|
|
610
|
+
- Changed: `pass_fds` refuses 0, 1 and 2 with a `ValueError` naming the number. The command's own stdin, stdout and
|
|
611
|
+
stderr take those numbers in the child, so a descriptor passed there was silently replaced.
|
|
612
|
+
- Changed, `AsyncExecutor`: a call held at its own `max_threads` waits, and `wait()` and `runningThreads` count it until
|
|
613
|
+
its last command has started. A command its limit held back starts ahead of the calls queued after it once
|
|
614
|
+
its slot frees (1.73: behind them). A thread that did not end within `cleanup(timeout)` stays in `wait()` and
|
|
615
|
+
`runningThreads` until it does (1.73 forgot it).
|
|
616
|
+
- Fix, `AsyncExecutor`: a dispatcher start that fails or is interrupted fails only its own call, which raises with its
|
|
617
|
+
commands skipped; they stay queued until the next call or `cleanup()`. 1.73 failed every other queued command with
|
|
618
|
+
`cannot start its thread`. A signal handler may call `cleanup()` while `run_commands()` starts the dispatcher (1.73
|
|
619
|
+
deadlocked).
|
|
620
|
+
- Fix: a Ctrl-C while multiCMD joins a finished thread leaves it to the next call, which joins and forgets it. 1.73 could
|
|
621
|
+
keep such a thread, with its command's output, until the executor ended, or for good if it ran a fire-and-forget command.
|
|
622
|
+
- Fix: in a child forked while commands ran, `AsyncExecutor.runningThreads` and `join_threads()` hold none of the
|
|
623
|
+
parent's threads. 1.73 listed the executor's, so a child that waited for `runningThreads` to be empty never ended.
|
|
624
|
+
|
|
625
|
+
## Upgrading to 1.73 from 1.72
|
|
626
|
+
|
|
627
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
628
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
629
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
630
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
631
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
632
|
+
negative value raised `ValueError`).
|
|
633
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
634
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
635
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
636
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
637
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
638
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
639
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
640
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
641
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
642
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
643
|
+
semaphore).
|
|
644
|
+
|
|
581
645
|
## Upgrading to 1.72 from 1.71
|
|
582
646
|
|
|
583
647
|
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
@@ -592,8 +656,8 @@ prints a table of what each version of `multiCMD.py` given to it did (`python3 s
|
|
|
592
656
|
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
593
657
|
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
594
658
|
ignored its exit).
|
|
595
|
-
- Known,
|
|
596
|
-
|
|
659
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
660
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
597
661
|
|
|
598
662
|
## Upgrading to 1.71 from 1.70
|
|
599
663
|
|