kthread


Namekthread JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/munshigroup/kthread
SummaryKillable threads in Python!
upload_time2022-02-19 23:33:47
maintainer
docs_urlNone
authorThe Munshi Group
requires_python
license
keywords threading threads terminate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            [![Build Status](https://travis-ci.org/munshigroup/kthread.svg?branch=master)](https://travis-ci.org/munshigroup/kthread)

# kthread
Killable threads in Python! 

## Purpose
The built-in `threading.Thread` class offers no simple solution to terminate a running thread.  `kthread.KThread` inherits `threading.Thread` and supplies methods named `exit()`, `kill()`, and `terminate()` that serve the same purpose: attempt to stop a thread if it's running.

## How it works
KThread leverages the CPython API to raise a `SystemExit` exception on a given thread.  Assuming that the thread is not blocked by an operating system call (such as `sleep`, `accept`, or `recv`), the thread will forcefully quit.

## DISCLAIMER
**TERMINATING THREADS MAY INTRODUCE INSTABILITY OR OTHER UNDESIRABLE EFFECTS IN YOUR PROGRAMS.  THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY.  THE MUNSHI GROUP CANNOT BE HELD LIABLE FOR ANY DAMAGES, LOSSES, OR EXPENSES INCURRED BY YOU OR YOUR ORGANIZATION WHILE USING THIS SOFTWARE.**

## Installation
To install this package, run the following command:

    $ pip install kthread

## Usage

    >>> import time
    >>> import kthread
    >>> import sys
    >>> def func():
    >>>     try:
    >>>         while True:
    >>>             time.sleep(0.2)
    >>>     finally:
    >>>         sys.stdout.write("Greetings from Vice City!\n")
    >>>         sys.stdout.flush()
    >>>
    >>> t = kthread.KThread(target = func, name = "KillableThread1")
    >>> t.start()
    >>> t.isAlive()
    True
    >>> t.terminate()
    Greetings from Vice City!
    >>> t.isAlive()
    False
    
## License
MIT



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/munshigroup/kthread",
    "name": "kthread",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "threading threads terminate",
    "author": "The Munshi Group",
    "author_email": "support@munshigroup.com",
    "download_url": "https://files.pythonhosted.org/packages/18/9b/aa1b48c3cf6e1a914ee5eee1fed77cd7217fb0a35c07c345da4ec5215cae/kthread-0.2.3.tar.gz",
    "platform": "",
    "description": "[![Build Status](https://travis-ci.org/munshigroup/kthread.svg?branch=master)](https://travis-ci.org/munshigroup/kthread)\n\n# kthread\nKillable threads in Python! \n\n## Purpose\nThe built-in `threading.Thread` class offers no simple solution to terminate a running thread.  `kthread.KThread` inherits `threading.Thread` and supplies methods named `exit()`, `kill()`, and `terminate()` that serve the same purpose: attempt to stop a thread if it's running.\n\n## How it works\nKThread leverages the CPython API to raise a `SystemExit` exception on a given thread.  Assuming that the thread is not blocked by an operating system call (such as `sleep`, `accept`, or `recv`), the thread will forcefully quit.\n\n## DISCLAIMER\n**TERMINATING THREADS MAY INTRODUCE INSTABILITY OR OTHER UNDESIRABLE EFFECTS IN YOUR PROGRAMS.  THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY.  THE MUNSHI GROUP CANNOT BE HELD LIABLE FOR ANY DAMAGES, LOSSES, OR EXPENSES INCURRED BY YOU OR YOUR ORGANIZATION WHILE USING THIS SOFTWARE.**\n\n## Installation\nTo install this package, run the following command:\n\n    $ pip install kthread\n\n## Usage\n\n    >>> import time\n    >>> import kthread\n    >>> import sys\n    >>> def func():\n    >>>     try:\n    >>>         while True:\n    >>>             time.sleep(0.2)\n    >>>     finally:\n    >>>         sys.stdout.write(\"Greetings from Vice City!\\n\")\n    >>>         sys.stdout.flush()\n    >>>\n    >>> t = kthread.KThread(target = func, name = \"KillableThread1\")\n    >>> t.start()\n    >>> t.isAlive()\n    True\n    >>> t.terminate()\n    Greetings from Vice City!\n    >>> t.isAlive()\n    False\n    \n## License\nMIT\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Killable threads in Python!",
    "version": "0.2.3",
    "split_keywords": [
        "threading",
        "threads",
        "terminate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d0e2a9c818b01fcc5811a4c8920e3196",
                "sha256": "808d3bb0ec6d573c8a00c10dfabe81b7e87d4ac945cb58335432c17f8db78ca6"
            },
            "downloads": -1,
            "filename": "kthread-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0e2a9c818b01fcc5811a4c8920e3196",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3898,
            "upload_time": "2022-02-19T23:33:45",
            "upload_time_iso_8601": "2022-02-19T23:33:45.994249Z",
            "url": "https://files.pythonhosted.org/packages/82/e3/4c26efac0a7e4e053eb0042164f3ea7cdee8dfc7eecda521e6d00ce45ea1/kthread-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d91b58af95ac583c0f7fbe63e1d53ce0",
                "sha256": "90e194e6a7ff903040c4133d3ea9037c908c4296bf5f582c7fdcf6325a04f9b4"
            },
            "downloads": -1,
            "filename": "kthread-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d91b58af95ac583c0f7fbe63e1d53ce0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3706,
            "upload_time": "2022-02-19T23:33:47",
            "upload_time_iso_8601": "2022-02-19T23:33:47.237782Z",
            "url": "https://files.pythonhosted.org/packages/18/9b/aa1b48c3cf6e1a914ee5eee1fed77cd7217fb0a35c07c345da4ec5215cae/kthread-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-19 23:33:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "munshigroup",
    "github_project": "kthread",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "kthread"
}
        
Elapsed time: 0.01771s