multisubprocess


Namemultisubprocess JSON
Version 0.13 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/multisubprocess
SummaryExecutes multiple subprocesses simultaneously (Windows only)
upload_time2023-04-25 21:28:38
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords subprocess simultaneously
VCS
bugtrack_url
requirements escape_windows_filepath kthread_sleep subprocess_alive subprocesskiller
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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! 



```python
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.
		
		
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/multisubprocess",
    "name": "multisubprocess",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "subprocess,simultaneously",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/68/3b/025987e51219c3fdfbbfbf2616cf074af5401d34823b0739e1326448de61/multisubprocess-0.13.tar.gz",
    "platform": null,
    "description": "# Executes multiple subprocesses concurrently and returns the output and return code of each subprocess. (Windows only)\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n## pip install multisubprocess\r\n\r\n#### Important: Cannot be executed directly from the console! \r\n\r\n\r\n\r\n```python\r\nfrom multisubprocess import multi_subprocess\r\n\r\nallqueries = []\r\nfor q in range(20):\r\n    allqueries.append([\"ls\", \"-la\", r\"E:\\textcompare\"])\r\n\r\nres = multi_subprocess(\r\n    allqueries,\r\n    byteinput=b\"\",\r\n    shell=False,\r\n    close_fds=False,\r\n    start_new_session=True,\r\n    bufsize=8192 * 40,\r\n    invisible=True,\r\n    timeout=15,\r\n    max_threads=5,\r\n    timeout_check_sleep=1,\r\n    kill_all_at_end=True,\r\n    blockbatch=False,\r\n)\r\n\r\n\r\n\r\n# Output from one subprocess\r\n# from pprint import pprint\r\n# from pprint import pprint\r\n# pprint(res[(7, 'ls', '-la', 'E:\\\\textcompare')])\r\n# defaultdict(<function <lambda> at 0x00000289E4B15750>,\r\n#             {'proc': <Popen: returncode: 0 args: ['ls', '-la', 'E:\\\\textcompare']>,\r\n#              'returncode': 0,\r\n#              'start': 1682433358.1547163,\r\n#              'stderr': <_io.BytesIO object at 0x00000289EFA2EFC0>,\r\n#              'stderrready': b'',\r\n#              'stdout': <_io.BytesIO object at 0x00000289EFA2EB10>,\r\n#              'stdoutready': b'total 18\\ndrwxr-xr-x 1 hansc hansc   0 Apr 24 20:'\r\n#                             b'33 .\\ndrwxr-xr-x 1 hansc hansc   0 Apr 24 20:33 .'\r\n#                             b'.\\n-rw-r--r-- 1 hansc hansc 321 Apr 24 15:41 text'\r\n#                             b'1.txt\\n-rw-r--r-- 1 hansc hansc 367 Apr 24 15:41 '\r\n#                             b'text2.txt\\n'})\r\n\r\n\r\n\r\n\r\n    \r\n\r\n    Args:\r\n        allcommands (str | list): List of commands to execute or one command as a string.\r\n        byteinput (bytes, optional): Input to be passed to the subprocess. Defaults to b\"\".\r\n        shell (bool, optional): Whether to use shell to execute the command. Defaults to False.\r\n        close_fds (bool, optional): Whether to close file descriptors. Defaults to True.\r\n        start_new_session (bool, optional): Whether to start a new session. Defaults to True.\r\n        bufsize (int, optional): Buffer size for the subprocess. Defaults to 1024 * 200.\r\n        invisible (bool, optional): Whether to run the subprocess invisibly. Defaults to True.\r\n        timeout (int, optional): Timeout for the subprocess. Defaults to 10000000.\r\n        max_threads (int | None, optional): Maximum number of threads to use. Defaults to None (Number of CPUs).\r\n        timeout_check_sleep (int, optional): Sleep time for timeout check. Defaults to 1.\r\n        kill_all_at_end (bool, optional): Whether to kill all subprocesses of the main process at the end. Defaults to True.\r\n        blockbatch (bool, optional): Whether to block batch processing. Defaults to False.\r\n        debug (bool, optional): Whether to print debug information. Defaults to False.\r\n        *args: Additional arguments to be passed to subprocess.Popen.\r\n        **kwargs: Additional keyword arguments to be passed to subprocess.Popen.\r\n\r\n    Returns:\r\n        dict: A dictionary containing the output and return code of each subprocess.\r\n\t\t\r\n\t\t\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Executes multiple subprocesses simultaneously (Windows only)",
    "version": "0.13",
    "split_keywords": [
        "subprocess",
        "simultaneously"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "42132115dba6f7443c144026564e00457b524d3dd7d537647f5f67cd1966c033",
                "md5": "db2937f5d92515f576de2c2b753d381a",
                "sha256": "5e5cbdd95ffa47977c9305936cf0a046e07457a4a410bdc17d41d8cad202ca3e"
            },
            "downloads": -1,
            "filename": "multisubprocess-0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db2937f5d92515f576de2c2b753d381a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9019,
            "upload_time": "2023-04-25T21:28:36",
            "upload_time_iso_8601": "2023-04-25T21:28:36.130571Z",
            "url": "https://files.pythonhosted.org/packages/42/13/2115dba6f7443c144026564e00457b524d3dd7d537647f5f67cd1966c033/multisubprocess-0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "683b025987e51219c3fdfbbfbf2616cf074af5401d34823b0739e1326448de61",
                "md5": "e51ba414e33573ff568835a1fbff05d8",
                "sha256": "134d9a1aa4bd9aacbc3dcea75e18d87e0864cc50887939f6521dd01842cdd558"
            },
            "downloads": -1,
            "filename": "multisubprocess-0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "e51ba414e33573ff568835a1fbff05d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6049,
            "upload_time": "2023-04-25T21:28:38",
            "upload_time_iso_8601": "2023-04-25T21:28:38.720945Z",
            "url": "https://files.pythonhosted.org/packages/68/3b/025987e51219c3fdfbbfbf2616cf074af5401d34823b0739e1326448de61/multisubprocess-0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-25 21:28:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "hansalemaos",
    "github_project": "multisubprocess",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "escape_windows_filepath",
            "specs": []
        },
        {
            "name": "kthread_sleep",
            "specs": []
        },
        {
            "name": "subprocess_alive",
            "specs": []
        },
        {
            "name": "subprocesskiller",
            "specs": []
        }
    ],
    "lcname": "multisubprocess"
}
        
Elapsed time: 0.08524s