Skip to main content

Executes multiple subprocesses concurrently and returns the output and return code of each subprocess. (Windows only)

Tested against Windows 10 / Python 3.10 / Anaconda

pip install multisubprocess

Important: Cannot be executed directly from the console!

from multisubprocess import multi_subprocess

allqueries = []
for q in range(20):
    allqueries.append(["ls", "-la", r"E:\textcompare"])

res = multi_subprocess(
    allqueries,
    byteinput=b"",
    shell=False,
    close_fds=False,
    start_new_session=True,
    bufsize=8192 * 40,
    invisible=True,
    timeout=15,
    max_threads=5,
    timeout_check_sleep=1,
    kill_all_at_end=True,
    blockbatch=False,
)



# Output from one subprocess
# from pprint import pprint
# from pprint import pprint
# pprint(res[(7, 'ls', '-la', 'E:\\textcompare')])
# defaultdict(<function <lambda> at 0x00000289E4B15750>,
#             {'proc': <Popen: returncode: 0 args: ['ls', '-la', 'E:\\textcompare']>,
#              'returncode': 0,
#              'start': 1682433358.1547163,
#              'stderr': <_io.BytesIO object at 0x00000289EFA2EFC0>,
#              'stderrready': b'',
#              'stdout': <_io.BytesIO object at 0x00000289EFA2EB10>,
#              'stdoutready': b'total 18\ndrwxr-xr-x 1 hansc hansc   0 Apr 24 20:'
#                             b'33 .\ndrwxr-xr-x 1 hansc hansc   0 Apr 24 20:33 .'
#                             b'.\n-rw-r--r-- 1 hansc hansc 321 Apr 24 15:41 text'
#                             b'1.txt\n-rw-r--r-- 1 hansc hansc 367 Apr 24 15:41 '
#                             b'text2.txt\n'})




    

    Args:
        allcommands (str | list): List of commands to execute or one command as a string.
        byteinput (bytes, optional): Input to be passed to the subprocess. Defaults to b"".
        shell (bool, optional): Whether to use shell to execute the command. Defaults to False.
        close_fds (bool, optional): Whether to close file descriptors. Defaults to True.
        start_new_session (bool, optional): Whether to start a new session. Defaults to True.
        bufsize (int, optional): Buffer size for the subprocess. Defaults to 1024 * 200.
        invisible (bool, optional): Whether to run the subprocess invisibly. Defaults to True.
        timeout (int, optional): Timeout for the subprocess. Defaults to 10000000.
        max_threads (int | None, optional): Maximum number of threads to use. Defaults to None (Number of CPUs).
        timeout_check_sleep (int, optional): Sleep time for timeout check. Defaults to 1.
        kill_all_at_end (bool, optional): Whether to kill all subprocesses of the main process at the end. Defaults to True.
        blockbatch (bool, optional): Whether to block batch processing. Defaults to False.
        debug (bool, optional): Whether to print debug information. Defaults to False.
        *args: Additional arguments to be passed to subprocess.Popen.
        **kwargs: Additional keyword arguments to be passed to subprocess.Popen.

    Returns:
        dict: A dictionary containing the output and return code of each subprocess.
		
		

Metadata

Release files for multisubprocess 0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multisubprocess 0.13
File Size Uploaded Provenance Actions
multisubprocess-0.13.tar.gz 6.0 kB Without provenance Details for multisubprocess-0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multisubprocess 0.13
File Interpreter ABI Platform Actions
multisubprocess-0.13-py3-none-any.whl Python 3 none any Details for multisubprocess-0.13-py3-none-any.whl

Total release size: 15.1 kB

Release files / multisubprocess-0.13.tar.gz

Download URL multisubprocess-0.13.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
134d9a1aa4bd9aacbc3dcea75e18d87e0864cc50887939f6521dd01842cdd558
BLAKE2b-256 checksum
How to use checksums
683b025987e51219c3fdfbbfbf2616cf074af5401d34823b0739e1326448de61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / multisubprocess-0.13-py3-none-any.whl

Download URL multisubprocess-0.13-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e5cbdd95ffa47977c9305936cf0a046e07457a4a410bdc17d41d8cad202ca3e
BLAKE2b-256 checksum
How to use checksums
42132115dba6f7443c144026564e00457b524d3dd7d537647f5f67cd1966c033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for multisubprocess 0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page