multiCMD 1.73__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.
Files changed (43) hide show
  1. {multicmd-1.73 → multicmd-1.75}/PKG-INFO +40 -5
  2. {multicmd-1.73 → multicmd-1.75}/README.md +39 -4
  3. {multicmd-1.73 → multicmd-1.75}/multiCMD.egg-info/PKG-INFO +40 -5
  4. {multicmd-1.73 → multicmd-1.75}/multiCMD.py +216 -223
  5. {multicmd-1.73 → multicmd-1.75}/tests/test_async_executor.py +629 -174
  6. {multicmd-1.73 → multicmd-1.75}/tests/test_env.py +2 -4
  7. {multicmd-1.73 → multicmd-1.75}/tests/test_pass_fds.py +24 -0
  8. {multicmd-1.73 → multicmd-1.75}/tests/test_run_commands.py +38 -1
  9. {multicmd-1.73 → multicmd-1.75}/tests/test_sudo.py +2 -2
  10. {multicmd-1.73 → multicmd-1.75}/LICENSE +0 -0
  11. {multicmd-1.73 → multicmd-1.75}/multiCMD.egg-info/SOURCES.txt +0 -0
  12. {multicmd-1.73 → multicmd-1.75}/multiCMD.egg-info/dependency_links.txt +0 -0
  13. {multicmd-1.73 → multicmd-1.75}/multiCMD.egg-info/entry_points.txt +0 -0
  14. {multicmd-1.73 → multicmd-1.75}/multiCMD.egg-info/top_level.txt +0 -0
  15. {multicmd-1.73 → multicmd-1.75}/scripts/multiCMD +0 -0
  16. {multicmd-1.73 → multicmd-1.75}/setup.cfg +0 -0
  17. {multicmd-1.73 → multicmd-1.75}/setup.py +0 -0
  18. {multicmd-1.73 → multicmd-1.75}/tests/test_api.py +0 -0
  19. {multicmd-1.73 → multicmd-1.75}/tests/test_cli.py +0 -0
  20. {multicmd-1.73 → multicmd-1.75}/tests/test_cli_closed_stdout.py +0 -0
  21. {multicmd-1.73 → multicmd-1.75}/tests/test_cli_failed_stdout.py +0 -0
  22. {multicmd-1.73 → multicmd-1.75}/tests/test_cli_input.py +0 -0
  23. {multicmd-1.73 → multicmd-1.75}/tests/test_cli_summary.py +0 -0
  24. {multicmd-1.73 → multicmd-1.75}/tests/test_display.py +0 -0
  25. {multicmd-1.73 → multicmd-1.75}/tests/test_embed.py +0 -0
  26. {multicmd-1.73 → multicmd-1.75}/tests/test_expand_ranges.py +0 -0
  27. {multicmd-1.73 → multicmd-1.75}/tests/test_handover.py +0 -0
  28. {multicmd-1.73 → multicmd-1.75}/tests/test_helpers.py +0 -0
  29. {multicmd-1.73 → multicmd-1.75}/tests/test_interrupts.py +0 -0
  30. {multicmd-1.73 → multicmd-1.75}/tests/test_packaging.py +0 -0
  31. {multicmd-1.73 → multicmd-1.75}/tests/test_parsing.py +0 -0
  32. {multicmd-1.73 → multicmd-1.75}/tests/test_ping.py +0 -0
  33. {multicmd-1.73 → multicmd-1.75}/tests/test_pool.py +0 -0
  34. {multicmd-1.73 → multicmd-1.75}/tests/test_process_groups.py +0 -0
  35. {multicmd-1.73 → multicmd-1.75}/tests/test_pty.py +0 -0
  36. {multicmd-1.73 → multicmd-1.75}/tests/test_reader.py +0 -0
  37. {multicmd-1.73 → multicmd-1.75}/tests/test_reader_quit.py +0 -0
  38. {multicmd-1.73 → multicmd-1.75}/tests/test_regressions.py +0 -0
  39. {multicmd-1.73 → multicmd-1.75}/tests/test_run_command.py +0 -0
  40. {multicmd-1.73 → multicmd-1.75}/tests/test_supervision.py +0 -0
  41. {multicmd-1.73 → multicmd-1.75}/tests/test_task.py +0 -0
  42. {multicmd-1.73 → multicmd-1.75}/tests/test_terminal_width.py +0 -0
  43. {multicmd-1.73 → 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.73
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 is any
354
- off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
355
- started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
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,7 +403,9 @@ 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
411
  starts each queued command only after taking a permit from the semaphore, so with a
@@ -503,6 +506,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
503
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
504
507
  exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
505
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.
506
513
  These and the other known limits are in [docs/limitations.md](docs/limitations.md).
507
514
 
508
515
  ## When stdout fails
@@ -587,6 +594,34 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
587
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
588
595
  prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
589
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
+
590
625
  ## Upgrading to 1.73 from 1.72
591
626
 
592
627
  - Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
@@ -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 is any
329
- off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
330
- started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
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,7 +378,9 @@ 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
386
  starts each queued command only after taking a permit from the semaphore, so with a
@@ -478,6 +481,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
478
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
479
482
  exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
480
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.
481
488
  These and the other known limits are in [docs/limitations.md](docs/limitations.md).
482
489
 
483
490
  ## When stdout fails
@@ -562,6 +569,34 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
562
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
563
570
  prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
564
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
+
565
600
  ## Upgrading to 1.73 from 1.72
566
601
 
567
602
  - Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multiCMD
3
- Version: 1.73
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 is any
354
- off POSIX. multiCMD neither closes nor duplicates them, so keep them open until the command has
355
- started ( with `wait_for_return=False` or `AsyncExecutor`, until its task's `start_time` is set ).
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,7 +403,9 @@ 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
411
  starts each queued command only after taking a permit from the semaphore, so with a
@@ -503,6 +506,10 @@ about 6,000 aimed Ctrl-Cs with 1.60, 3 with 1.61): the same message, and the nex
503
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
504
507
  exec of the Python binary itself hangs (a venv on an NFS mount that stopped answering), it does nothing until the mount
505
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.
506
513
  These and the other known limits are in [docs/limitations.md](docs/limitations.md).
507
514
 
508
515
  ## When stdout fails
@@ -587,6 +594,34 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
587
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
588
595
  prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
589
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
+
590
625
  ## Upgrading to 1.73 from 1.72
591
626
 
592
627
  - Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or