gracefully-kill


Namegracefully-kill JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/gracefully_kill
SummaryTerminates a subprocess gracefully, if it doesn't work, it will be killed (Windows only)
upload_time2023-06-05 15:49:51
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords subprocess kill
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Terminates a subprocess gracefully, if it doesn't work, it will be killed (Windows only)

## pip install gracefully_kill

#### Tested against Windows 10 / Python 3.10 / Anaconda


The function attempts to terminate the subprocess gracefully by closing its standard input, output, and error streams, waiting for a specified timeout, 
and finally terminating the process. 
This allows the subprocess to clean up its resources and exit properly.
The function checks if the process is still alive after termination attempts. 
If it is, it uses the taskkill_force_pid_children function from the taskkill module to forcibly terminate 
any child processes associated with the given process ID. 
This ensures that the entire process hierarchy is terminated if necessary.


```python
pro=subprocess.Popen('ping -t 8.8.8.8')
kill_process(pro, timeout=1)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/gracefully_kill",
    "name": "gracefully-kill",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "subprocess,kill",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/74/3b71e16a164e442ce86e8f95c4eeb22b0d7573727851578d58b08df0d877/gracefully_kill-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Terminates a subprocess gracefully, if it doesn't work, it will be killed (Windows only)\r\n\r\n## pip install gracefully_kill\r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n\r\nThe function attempts to terminate the subprocess gracefully by closing its standard input, output, and error streams, waiting for a specified timeout, \r\nand finally terminating the process. \r\nThis allows the subprocess to clean up its resources and exit properly.\r\nThe function checks if the process is still alive after termination attempts. \r\nIf it is, it uses the taskkill_force_pid_children function from the taskkill module to forcibly terminate \r\nany child processes associated with the given process ID. \r\nThis ensures that the entire process hierarchy is terminated if necessary.\r\n\r\n\r\n```python\r\npro=subprocess.Popen('ping -t 8.8.8.8')\r\nkill_process(pro, timeout=1)\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Terminates a subprocess gracefully, if it doesn't work, it will be killed (Windows only)",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/gracefully_kill"
    },
    "split_keywords": [
        "subprocess",
        "kill"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3230564f25d7a6a1dd801c1e60308dfb5d5b34111d5ad7153748f70b3fe362f7",
                "md5": "60c6451778440a2247e7d3b956512129",
                "sha256": "cde5bfc8ff6882374d208e63aeb79b05243f4108f0580dc8107d70b03c08a028"
            },
            "downloads": -1,
            "filename": "gracefully_kill-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "60c6451778440a2247e7d3b956512129",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4886,
            "upload_time": "2023-06-05T15:49:49",
            "upload_time_iso_8601": "2023-06-05T15:49:49.003124Z",
            "url": "https://files.pythonhosted.org/packages/32/30/564f25d7a6a1dd801c1e60308dfb5d5b34111d5ad7153748f70b3fe362f7/gracefully_kill-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f743b71e16a164e442ce86e8f95c4eeb22b0d7573727851578d58b08df0d877",
                "md5": "7d69da6d3f4d02eea4d98171e7fcae19",
                "sha256": "3f9aae40ebea46b0ca703b51990a0a5b5a7b8d30225ccf3cac3c127e148ec09e"
            },
            "downloads": -1,
            "filename": "gracefully_kill-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "7d69da6d3f4d02eea4d98171e7fcae19",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3399,
            "upload_time": "2023-06-05T15:49:51",
            "upload_time_iso_8601": "2023-06-05T15:49:51.163458Z",
            "url": "https://files.pythonhosted.org/packages/3f/74/3b71e16a164e442ce86e8f95c4eeb22b0d7573727851578d58b08df0d877/gracefully_kill-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-05 15:49:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "gracefully_kill",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "gracefully-kill"
}
        
Elapsed time: 0.11279s