multiCMD 1.57__tar.gz → 1.59__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.57 → multicmd-1.59}/PKG-INFO +53 -8
- {multicmd-1.57 → multicmd-1.59}/README.md +52 -7
- {multicmd-1.57 → multicmd-1.59}/multiCMD.egg-info/PKG-INFO +53 -8
- {multicmd-1.57 → multicmd-1.59}/multiCMD.egg-info/SOURCES.txt +4 -0
- {multicmd-1.57 → multicmd-1.59}/multiCMD.egg-info/entry_points.txt +0 -1
- {multicmd-1.57 → multicmd-1.59}/multiCMD.py +152 -38
- multicmd-1.59/scripts/multiCMD +6 -0
- {multicmd-1.57 → multicmd-1.59}/setup.py +3 -1
- {multicmd-1.57 → multicmd-1.59}/tests/test_env.py +22 -7
- multicmd-1.59/tests/test_handover.py +109 -0
- multicmd-1.59/tests/test_packaging.py +26 -0
- multicmd-1.59/tests/test_pass_fds.py +145 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_run_command.py +3 -0
- {multicmd-1.57 → multicmd-1.59}/LICENSE +0 -0
- {multicmd-1.57 → multicmd-1.59}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.57 → multicmd-1.59}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.57 → multicmd-1.59}/setup.cfg +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_api.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_async_executor.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_cli.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_cli_input.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_cli_summary.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_display.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_expand_ranges.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_helpers.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_interrupts.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_parsing.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_ping.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_pool.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_process_groups.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_pty.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_reader.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_regressions.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_run_commands.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_sudo.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_supervision.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/tests/test_task.py +0 -0
- {multicmd-1.57 → multicmd-1.59}/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.59
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -56,7 +56,7 @@ It works both as a command-line tool and as an importable wrapper around
|
|
|
56
56
|
pip install multiCMD
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
This installs the module and three equivalent
|
|
59
|
+
This installs the module and three equivalent commands:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
mcmd
|
|
@@ -326,6 +326,26 @@ overrides. `sudo` resets the environment by default, so with `use_sudo` they may
|
|
|
326
326
|
command. On the command line: `mcmd -e LC_ALL=C -e UNSET_ME "cmd"`; `-n` shows them as
|
|
327
327
|
`env LC_ALL=C cmd` ( `env -i ...` for a whole environment ).
|
|
328
328
|
|
|
329
|
+
### Descriptors a command inherits
|
|
330
|
+
|
|
331
|
+
```python
|
|
332
|
+
fd = os.open("out/file", os.O_WRONLY) # a file this process holds
|
|
333
|
+
multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # cp writes it through its own copy
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
337
|
+
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
338
|
+
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
339
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so is any
|
|
340
|
+
off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
|
|
341
|
+
started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
342
|
+
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
343
|
+
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
344
|
+
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
345
|
+
`closefrom_override` ); with `shell=True` the shell inherits them too. `AsyncExecutor` takes it as a
|
|
346
|
+
default a call overrides. There is no command-line form: nothing on a command line holds a
|
|
347
|
+
descriptor.
|
|
348
|
+
|
|
329
349
|
`raise_error=True` raises `multiCMD.CommandError`; its `.tasks` holds the failed `Task`
|
|
330
350
|
objects and its message lists each one with its return code and last error line.
|
|
331
351
|
`Task` also records `start_time`, `end_time` and `duration`. With `dry_run=True` nothing
|
|
@@ -432,9 +452,10 @@ stderr, unless quiet.
|
|
|
432
452
|
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers, nothing
|
|
433
453
|
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
434
454
|
|
|
435
|
-
A command is registered from the moment `Popen` returns it
|
|
436
|
-
|
|
437
|
-
|
|
455
|
+
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
456
|
+
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
457
|
+
starts a command keeps that command from running at all; on 3.11+ such a Ctrl-C (a window of some
|
|
458
|
+
50-70 µs per start) can leave it running, unknown to `kill_all()`. Two Ctrl-Cs microseconds apart can leave a command running, still registered, until
|
|
438
459
|
`kill_all()` or the exit stops it. On Python 3.6-3.9, which raise a Ctrl-C at nearly any instruction,
|
|
439
460
|
even one at a few points between the steps of a run can leave its command registered but not signalled.
|
|
440
461
|
On Python 3.6-3.9 and 3.14 a Ctrl-C at the wrong instruction of a `with` on a lock can leave it held: one of
|
|
@@ -449,13 +470,14 @@ These and the other known limits are in [docs/limitations.md](docs/limitations.m
|
|
|
449
470
|
run_command(command, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
450
471
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
451
472
|
wait_for_return=True, sem=None, use_sudo=..., raise_error=False,
|
|
452
|
-
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None
|
|
473
|
+
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None,
|
|
474
|
+
pass_fds=())
|
|
453
475
|
|
|
454
476
|
run_commands(commands, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
455
477
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
456
478
|
parse=False, wait_for_return=True, sem=None, use_sudo=...,
|
|
457
479
|
raise_error=False, prefix=False, color=None, pty=False, shell=False,
|
|
458
|
-
env=None, extra_env=None)
|
|
480
|
+
env=None, extra_env=None, pass_fds=())
|
|
459
481
|
|
|
460
482
|
ping(hosts, timeout=1, max_threads=0, ...) # returns True/False reachability
|
|
461
483
|
join_threads(threads=..., timeout=None) # join fire-and-forget threads
|
|
@@ -465,7 +487,7 @@ set_sudo(use_sudo) # enable/disable sudo globally
|
|
|
465
487
|
class Task: # command, returncode, stdout, stderr, start_time, end_time, duration
|
|
466
488
|
class CommandError: # raised by raise_error=True; .tasks = the failed Tasks
|
|
467
489
|
class AsyncExecutor: # run_command(s), wait, join, stop, cleanup, get_results, get_return_codes;
|
|
468
|
-
# takes the options above, env / extra_env as defaults a call overrides
|
|
490
|
+
# takes the options above, env / extra_env / pass_fds as defaults a call overrides
|
|
469
491
|
```
|
|
470
492
|
|
|
471
493
|
The module also bundles a few terminal/formatting helpers used internally and
|
|
@@ -491,6 +513,29 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
491
513
|
|
|
492
514
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
493
515
|
|
|
516
|
+
## Upgrading to 1.59 from 1.58
|
|
517
|
+
|
|
518
|
+
- Nothing needs doing to upgrade.
|
|
519
|
+
- Fix, Python 3.6 to 3.10: a Ctrl-C, or what your own signal handler raises (a SIGTERM handler's `sys.exit()`),
|
|
520
|
+
inside `Popen` as a serial run starts a command no longer leaves that command running, unknown to `kill_all()`
|
|
521
|
+
and the exit hook. The exec wrapper now waits for one byte that multiCMD writes on a pipe once the command is
|
|
522
|
+
registered; an interrupted start closes the pipe instead, and the wrapper exits 125 without running anything.
|
|
523
|
+
The window was the whole fork and wait for the exec, about 2.5 ms per start of a large program on 3.6: hpcp's copy
|
|
524
|
+
workers ran 66 such commands in 200 early stops on 3.6 and 33 in 200 on 3.10, and none with 1.59. On 3.11+ the
|
|
525
|
+
window stays (about 50 µs per start; 3 in 200 in the same test), see [docs/limitations.md](docs/limitations.md).
|
|
526
|
+
- New: `pass_fds=` on `run_command`, `run_commands` and `AsyncExecutor` (a constructor default, overridden per call):
|
|
527
|
+
descriptors a command inherits, at the same numbers, as `subprocess`'s `pass_fds` (POSIX only). The default passes
|
|
528
|
+
nothing, as before. See "Descriptors a command inherits" above.
|
|
529
|
+
|
|
530
|
+
## Upgrading to 1.58 from 1.57
|
|
531
|
+
|
|
532
|
+
- The `multiCMD` command is now a script file, not an entry point, so `entry_points.txt` no longer has two names that differ only in case. All three commands still work the same way, except in the venv case below. From 1.58 on, stock pip 9 on EL7 and EL8 upgrades and uninstalls multiCMD without `configparser.DuplicateOptionError`.
|
|
533
|
+
- With pip 9, the pip of EL7 and EL8 (`pip3 --version`), upgrading from 1.57 or earlier and `pip3 uninstall multiCMD` of those releases stop with `configparser.DuplicateOptionError: ... option 'multicmd' in section 'console_scripts' already exists`, and nothing changes: the installed release keeps working. Run `pip3 install -U pip` once, then upgrade or uninstall.
|
|
534
|
+
- With `--user` the same happens, except that `pip3 install --user -U multiCMD` with no version does not stop: it installs the new release, which works, and leaves the old release's metadata behind. `pip3 list` then shows the old release after `pip3 uninstall multiCMD`, and the next uninstall stops with that error. To avoid this, run `pip3 install --user -U pip` once first. If it has already happened, run that, run `pip3 uninstall multiCMD` until it says multiCMD is not installed, and install again. From 1.58 on the same upgrade leaves the metadata too, but with no error: `pip3 uninstall multiCMD` takes one run per release left.
|
|
535
|
+
- Without `--user`, with multiCMD 1.57 or earlier installed, `pip3 install -U hpcp`, `statblk` or `statbtrfs` stops the same way once a newer multiCMD is out, because pip 9 upgrades dependencies too. `pip3 install -U --no-deps hpcp` gets past it.
|
|
536
|
+
- With pip 10 or later, in a venv whose path has a space or is too long for the kernel's `#!` line, the `multiCMD` spelling does not start (the error varies: "bad interpreter", `import: command not found`), because pip gives a script file a plain `#!` line: use `multicmd`. With pip 9 no spelling starts in such a venv, as in 1.57. uv and system or `--user` installs are not affected.
|
|
537
|
+
- An embedded copy made by the generator now falls back from any failure to import the installed multiCMD, not only the three errors it named.
|
|
538
|
+
|
|
494
539
|
## Upgrading to 1.57 from 1.56
|
|
495
540
|
|
|
496
541
|
- Faster command starts on Python 3.6 - 3.10: the wrapper that puts a command in its own process group
|
|
@@ -30,7 +30,7 @@ It works both as a command-line tool and as an importable wrapper around
|
|
|
30
30
|
pip install multiCMD
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
This installs the module and three equivalent
|
|
33
|
+
This installs the module and three equivalent commands:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
mcmd
|
|
@@ -300,6 +300,26 @@ overrides. `sudo` resets the environment by default, so with `use_sudo` they may
|
|
|
300
300
|
command. On the command line: `mcmd -e LC_ALL=C -e UNSET_ME "cmd"`; `-n` shows them as
|
|
301
301
|
`env LC_ALL=C cmd` ( `env -i ...` for a whole environment ).
|
|
302
302
|
|
|
303
|
+
### Descriptors a command inherits
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
fd = os.open("out/file", os.O_WRONLY) # a file this process holds
|
|
307
|
+
multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # cp writes it through its own copy
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
311
|
+
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
312
|
+
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
313
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so is any
|
|
314
|
+
off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
|
|
315
|
+
started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
316
|
+
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
317
|
+
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
318
|
+
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
319
|
+
`closefrom_override` ); with `shell=True` the shell inherits them too. `AsyncExecutor` takes it as a
|
|
320
|
+
default a call overrides. There is no command-line form: nothing on a command line holds a
|
|
321
|
+
descriptor.
|
|
322
|
+
|
|
303
323
|
`raise_error=True` raises `multiCMD.CommandError`; its `.tasks` holds the failed `Task`
|
|
304
324
|
objects and its message lists each one with its return code and last error line.
|
|
305
325
|
`Task` also records `start_time`, `end_time` and `duration`. With `dry_run=True` nothing
|
|
@@ -406,9 +426,10 @@ stderr, unless quiet.
|
|
|
406
426
|
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers, nothing
|
|
407
427
|
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
408
428
|
|
|
409
|
-
A command is registered from the moment `Popen` returns it
|
|
410
|
-
|
|
411
|
-
|
|
429
|
+
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
430
|
+
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
431
|
+
starts a command keeps that command from running at all; on 3.11+ such a Ctrl-C (a window of some
|
|
432
|
+
50-70 µs per start) can leave it running, unknown to `kill_all()`. Two Ctrl-Cs microseconds apart can leave a command running, still registered, until
|
|
412
433
|
`kill_all()` or the exit stops it. On Python 3.6-3.9, which raise a Ctrl-C at nearly any instruction,
|
|
413
434
|
even one at a few points between the steps of a run can leave its command registered but not signalled.
|
|
414
435
|
On Python 3.6-3.9 and 3.14 a Ctrl-C at the wrong instruction of a `with` on a lock can leave it held: one of
|
|
@@ -423,13 +444,14 @@ These and the other known limits are in [docs/limitations.md](docs/limitations.m
|
|
|
423
444
|
run_command(command, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
424
445
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
425
446
|
wait_for_return=True, sem=None, use_sudo=..., raise_error=False,
|
|
426
|
-
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None
|
|
447
|
+
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None,
|
|
448
|
+
pass_fds=())
|
|
427
449
|
|
|
428
450
|
run_commands(commands, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
429
451
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
430
452
|
parse=False, wait_for_return=True, sem=None, use_sudo=...,
|
|
431
453
|
raise_error=False, prefix=False, color=None, pty=False, shell=False,
|
|
432
|
-
env=None, extra_env=None)
|
|
454
|
+
env=None, extra_env=None, pass_fds=())
|
|
433
455
|
|
|
434
456
|
ping(hosts, timeout=1, max_threads=0, ...) # returns True/False reachability
|
|
435
457
|
join_threads(threads=..., timeout=None) # join fire-and-forget threads
|
|
@@ -439,7 +461,7 @@ set_sudo(use_sudo) # enable/disable sudo globally
|
|
|
439
461
|
class Task: # command, returncode, stdout, stderr, start_time, end_time, duration
|
|
440
462
|
class CommandError: # raised by raise_error=True; .tasks = the failed Tasks
|
|
441
463
|
class AsyncExecutor: # run_command(s), wait, join, stop, cleanup, get_results, get_return_codes;
|
|
442
|
-
# takes the options above, env / extra_env as defaults a call overrides
|
|
464
|
+
# takes the options above, env / extra_env / pass_fds as defaults a call overrides
|
|
443
465
|
```
|
|
444
466
|
|
|
445
467
|
The module also bundles a few terminal/formatting helpers used internally and
|
|
@@ -465,6 +487,29 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
465
487
|
|
|
466
488
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
467
489
|
|
|
490
|
+
## Upgrading to 1.59 from 1.58
|
|
491
|
+
|
|
492
|
+
- Nothing needs doing to upgrade.
|
|
493
|
+
- Fix, Python 3.6 to 3.10: a Ctrl-C, or what your own signal handler raises (a SIGTERM handler's `sys.exit()`),
|
|
494
|
+
inside `Popen` as a serial run starts a command no longer leaves that command running, unknown to `kill_all()`
|
|
495
|
+
and the exit hook. The exec wrapper now waits for one byte that multiCMD writes on a pipe once the command is
|
|
496
|
+
registered; an interrupted start closes the pipe instead, and the wrapper exits 125 without running anything.
|
|
497
|
+
The window was the whole fork and wait for the exec, about 2.5 ms per start of a large program on 3.6: hpcp's copy
|
|
498
|
+
workers ran 66 such commands in 200 early stops on 3.6 and 33 in 200 on 3.10, and none with 1.59. On 3.11+ the
|
|
499
|
+
window stays (about 50 µs per start; 3 in 200 in the same test), see [docs/limitations.md](docs/limitations.md).
|
|
500
|
+
- New: `pass_fds=` on `run_command`, `run_commands` and `AsyncExecutor` (a constructor default, overridden per call):
|
|
501
|
+
descriptors a command inherits, at the same numbers, as `subprocess`'s `pass_fds` (POSIX only). The default passes
|
|
502
|
+
nothing, as before. See "Descriptors a command inherits" above.
|
|
503
|
+
|
|
504
|
+
## Upgrading to 1.58 from 1.57
|
|
505
|
+
|
|
506
|
+
- The `multiCMD` command is now a script file, not an entry point, so `entry_points.txt` no longer has two names that differ only in case. All three commands still work the same way, except in the venv case below. From 1.58 on, stock pip 9 on EL7 and EL8 upgrades and uninstalls multiCMD without `configparser.DuplicateOptionError`.
|
|
507
|
+
- With pip 9, the pip of EL7 and EL8 (`pip3 --version`), upgrading from 1.57 or earlier and `pip3 uninstall multiCMD` of those releases stop with `configparser.DuplicateOptionError: ... option 'multicmd' in section 'console_scripts' already exists`, and nothing changes: the installed release keeps working. Run `pip3 install -U pip` once, then upgrade or uninstall.
|
|
508
|
+
- With `--user` the same happens, except that `pip3 install --user -U multiCMD` with no version does not stop: it installs the new release, which works, and leaves the old release's metadata behind. `pip3 list` then shows the old release after `pip3 uninstall multiCMD`, and the next uninstall stops with that error. To avoid this, run `pip3 install --user -U pip` once first. If it has already happened, run that, run `pip3 uninstall multiCMD` until it says multiCMD is not installed, and install again. From 1.58 on the same upgrade leaves the metadata too, but with no error: `pip3 uninstall multiCMD` takes one run per release left.
|
|
509
|
+
- Without `--user`, with multiCMD 1.57 or earlier installed, `pip3 install -U hpcp`, `statblk` or `statbtrfs` stops the same way once a newer multiCMD is out, because pip 9 upgrades dependencies too. `pip3 install -U --no-deps hpcp` gets past it.
|
|
510
|
+
- With pip 10 or later, in a venv whose path has a space or is too long for the kernel's `#!` line, the `multiCMD` spelling does not start (the error varies: "bad interpreter", `import: command not found`), because pip gives a script file a plain `#!` line: use `multicmd`. With pip 9 no spelling starts in such a venv, as in 1.57. uv and system or `--user` installs are not affected.
|
|
511
|
+
- An embedded copy made by the generator now falls back from any failure to import the installed multiCMD, not only the three errors it named.
|
|
512
|
+
|
|
468
513
|
## Upgrading to 1.57 from 1.56
|
|
469
514
|
|
|
470
515
|
- Faster command starts on Python 3.6 - 3.10: the wrapper that puts a command in its own process group
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.59
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -56,7 +56,7 @@ It works both as a command-line tool and as an importable wrapper around
|
|
|
56
56
|
pip install multiCMD
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
This installs the module and three equivalent
|
|
59
|
+
This installs the module and three equivalent commands:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
62
|
mcmd
|
|
@@ -326,6 +326,26 @@ overrides. `sudo` resets the environment by default, so with `use_sudo` they may
|
|
|
326
326
|
command. On the command line: `mcmd -e LC_ALL=C -e UNSET_ME "cmd"`; `-n` shows them as
|
|
327
327
|
`env LC_ALL=C cmd` ( `env -i ...` for a whole environment ).
|
|
328
328
|
|
|
329
|
+
### Descriptors a command inherits
|
|
330
|
+
|
|
331
|
+
```python
|
|
332
|
+
fd = os.open("out/file", os.O_WRONLY) # a file this process holds
|
|
333
|
+
multiCMD.run_command(["cp", "src/file", "/dev/fd/%d" % fd], pass_fds=(fd,)) # cp writes it through its own copy
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
`pass_fds` names descriptors the command inherits, at the same numbers, as `subprocess`'s `pass_fds`
|
|
337
|
+
( POSIX only ). It takes an int, an object with `fileno()`, or an iterable of either; the default
|
|
338
|
+
passes nothing, and every descriptor past 2 is closed in the command, as before. It is checked
|
|
339
|
+
before anything runs: a negative, `bool` or closed descriptor is a `ValueError`, and so is any
|
|
340
|
+
off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
|
|
341
|
+
started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
|
|
342
|
+
The command opens its own copy by name: `/dev/fd/N` ( on Linux `/proc/self/fd/N`, a new open of the
|
|
343
|
+
file; on macOS a `dup` that shares the offset and ignores the open's flags ). With `use_sudo`, sudo
|
|
344
|
+
closes descriptors past 2 unless its policy lets the caller keep them ( `sudo -C`,
|
|
345
|
+
`closefrom_override` ); with `shell=True` the shell inherits them too. `AsyncExecutor` takes it as a
|
|
346
|
+
default a call overrides. There is no command-line form: nothing on a command line holds a
|
|
347
|
+
descriptor.
|
|
348
|
+
|
|
329
349
|
`raise_error=True` raises `multiCMD.CommandError`; its `.tasks` holds the failed `Task`
|
|
330
350
|
objects and its message lists each one with its return code and last error line.
|
|
331
351
|
`Task` also records `start_time`, `end_time` and `duration`. With `dry_run=True` nothing
|
|
@@ -432,9 +452,10 @@ stderr, unless quiet.
|
|
|
432
452
|
multiCMD never touches SIGINT's handler (`mcmd` sets its own SIGTERM / SIGHUP handlers, nothing
|
|
433
453
|
else). What your handler raises while a call waits for its commands is handled as a Ctrl-C.
|
|
434
454
|
|
|
435
|
-
A command is registered from the moment `Popen` returns it
|
|
436
|
-
|
|
437
|
-
|
|
455
|
+
A command is registered from the moment `Popen` returns it. Before Python 3.11 the exec wrapper runs
|
|
456
|
+
the command only once it is registered, so a Ctrl-C that Python raises inside `Popen` as a serial run
|
|
457
|
+
starts a command keeps that command from running at all; on 3.11+ such a Ctrl-C (a window of some
|
|
458
|
+
50-70 µs per start) can leave it running, unknown to `kill_all()`. Two Ctrl-Cs microseconds apart can leave a command running, still registered, until
|
|
438
459
|
`kill_all()` or the exit stops it. On Python 3.6-3.9, which raise a Ctrl-C at nearly any instruction,
|
|
439
460
|
even one at a few points between the steps of a run can leave its command registered but not signalled.
|
|
440
461
|
On Python 3.6-3.9 and 3.14 a Ctrl-C at the wrong instruction of a `with` on a lock can leave it held: one of
|
|
@@ -449,13 +470,14 @@ These and the other known limits are in [docs/limitations.md](docs/limitations.m
|
|
|
449
470
|
run_command(command, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
450
471
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
451
472
|
wait_for_return=True, sem=None, use_sudo=..., raise_error=False,
|
|
452
|
-
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None
|
|
473
|
+
prefix=False, color=None, pty=False, shell=False, env=None, extra_env=None,
|
|
474
|
+
pass_fds=())
|
|
453
475
|
|
|
454
476
|
run_commands(commands, timeout=0, max_threads=1, quiet=False, dry_run=False,
|
|
455
477
|
with_stdErr=False, return_code_only=False, return_object=False,
|
|
456
478
|
parse=False, wait_for_return=True, sem=None, use_sudo=...,
|
|
457
479
|
raise_error=False, prefix=False, color=None, pty=False, shell=False,
|
|
458
|
-
env=None, extra_env=None)
|
|
480
|
+
env=None, extra_env=None, pass_fds=())
|
|
459
481
|
|
|
460
482
|
ping(hosts, timeout=1, max_threads=0, ...) # returns True/False reachability
|
|
461
483
|
join_threads(threads=..., timeout=None) # join fire-and-forget threads
|
|
@@ -465,7 +487,7 @@ set_sudo(use_sudo) # enable/disable sudo globally
|
|
|
465
487
|
class Task: # command, returncode, stdout, stderr, start_time, end_time, duration
|
|
466
488
|
class CommandError: # raised by raise_error=True; .tasks = the failed Tasks
|
|
467
489
|
class AsyncExecutor: # run_command(s), wait, join, stop, cleanup, get_results, get_return_codes;
|
|
468
|
-
# takes the options above, env / extra_env as defaults a call overrides
|
|
490
|
+
# takes the options above, env / extra_env / pass_fds as defaults a call overrides
|
|
469
491
|
```
|
|
470
492
|
|
|
471
493
|
The module also bundles a few terminal/formatting helpers used internally and
|
|
@@ -491,6 +513,29 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
491
513
|
|
|
492
514
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
493
515
|
|
|
516
|
+
## Upgrading to 1.59 from 1.58
|
|
517
|
+
|
|
518
|
+
- Nothing needs doing to upgrade.
|
|
519
|
+
- Fix, Python 3.6 to 3.10: a Ctrl-C, or what your own signal handler raises (a SIGTERM handler's `sys.exit()`),
|
|
520
|
+
inside `Popen` as a serial run starts a command no longer leaves that command running, unknown to `kill_all()`
|
|
521
|
+
and the exit hook. The exec wrapper now waits for one byte that multiCMD writes on a pipe once the command is
|
|
522
|
+
registered; an interrupted start closes the pipe instead, and the wrapper exits 125 without running anything.
|
|
523
|
+
The window was the whole fork and wait for the exec, about 2.5 ms per start of a large program on 3.6: hpcp's copy
|
|
524
|
+
workers ran 66 such commands in 200 early stops on 3.6 and 33 in 200 on 3.10, and none with 1.59. On 3.11+ the
|
|
525
|
+
window stays (about 50 µs per start; 3 in 200 in the same test), see [docs/limitations.md](docs/limitations.md).
|
|
526
|
+
- New: `pass_fds=` on `run_command`, `run_commands` and `AsyncExecutor` (a constructor default, overridden per call):
|
|
527
|
+
descriptors a command inherits, at the same numbers, as `subprocess`'s `pass_fds` (POSIX only). The default passes
|
|
528
|
+
nothing, as before. See "Descriptors a command inherits" above.
|
|
529
|
+
|
|
530
|
+
## Upgrading to 1.58 from 1.57
|
|
531
|
+
|
|
532
|
+
- The `multiCMD` command is now a script file, not an entry point, so `entry_points.txt` no longer has two names that differ only in case. All three commands still work the same way, except in the venv case below. From 1.58 on, stock pip 9 on EL7 and EL8 upgrades and uninstalls multiCMD without `configparser.DuplicateOptionError`.
|
|
533
|
+
- With pip 9, the pip of EL7 and EL8 (`pip3 --version`), upgrading from 1.57 or earlier and `pip3 uninstall multiCMD` of those releases stop with `configparser.DuplicateOptionError: ... option 'multicmd' in section 'console_scripts' already exists`, and nothing changes: the installed release keeps working. Run `pip3 install -U pip` once, then upgrade or uninstall.
|
|
534
|
+
- With `--user` the same happens, except that `pip3 install --user -U multiCMD` with no version does not stop: it installs the new release, which works, and leaves the old release's metadata behind. `pip3 list` then shows the old release after `pip3 uninstall multiCMD`, and the next uninstall stops with that error. To avoid this, run `pip3 install --user -U pip` once first. If it has already happened, run that, run `pip3 uninstall multiCMD` until it says multiCMD is not installed, and install again. From 1.58 on the same upgrade leaves the metadata too, but with no error: `pip3 uninstall multiCMD` takes one run per release left.
|
|
535
|
+
- Without `--user`, with multiCMD 1.57 or earlier installed, `pip3 install -U hpcp`, `statblk` or `statbtrfs` stops the same way once a newer multiCMD is out, because pip 9 upgrades dependencies too. `pip3 install -U --no-deps hpcp` gets past it.
|
|
536
|
+
- With pip 10 or later, in a venv whose path has a space or is too long for the kernel's `#!` line, the `multiCMD` spelling does not start (the error varies: "bad interpreter", `import: command not found`), because pip gives a script file a plain `#!` line: use `multicmd`. With pip 9 no spelling starts in such a venv, as in 1.57. uv and system or `--user` installs are not affected.
|
|
537
|
+
- An embedded copy made by the generator now falls back from any failure to import the installed multiCMD, not only the three errors it named.
|
|
538
|
+
|
|
494
539
|
## Upgrading to 1.57 from 1.56
|
|
495
540
|
|
|
496
541
|
- Faster command starts on Python 3.6 - 3.10: the wrapper that puts a command in its own process group
|
|
@@ -7,6 +7,7 @@ multiCMD.egg-info/SOURCES.txt
|
|
|
7
7
|
multiCMD.egg-info/dependency_links.txt
|
|
8
8
|
multiCMD.egg-info/entry_points.txt
|
|
9
9
|
multiCMD.egg-info/top_level.txt
|
|
10
|
+
scripts/multiCMD
|
|
10
11
|
tests/test_api.py
|
|
11
12
|
tests/test_async_executor.py
|
|
12
13
|
tests/test_cli.py
|
|
@@ -15,9 +16,12 @@ tests/test_cli_summary.py
|
|
|
15
16
|
tests/test_display.py
|
|
16
17
|
tests/test_env.py
|
|
17
18
|
tests/test_expand_ranges.py
|
|
19
|
+
tests/test_handover.py
|
|
18
20
|
tests/test_helpers.py
|
|
19
21
|
tests/test_interrupts.py
|
|
22
|
+
tests/test_packaging.py
|
|
20
23
|
tests/test_parsing.py
|
|
24
|
+
tests/test_pass_fds.py
|
|
21
25
|
tests/test_ping.py
|
|
22
26
|
tests/test_pool.py
|
|
23
27
|
tests/test_process_groups.py
|