pyrunnable


Namepyrunnable JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2025-10-21 22:48:15
maintainernbdy
docs_urlNone
authornbdy
requires_python>=3.6
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyrunnable

Lightweight convenience wrapper around `threading.Thread` with lifecycle hooks.

[![PyPI](https://img.shields.io/pypi/v/pyrunnable.svg)](https://pypi.org/project/pyrunnable/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pyrunnable.svg)](https://pypi.org/project/pyrunnable/)
[![License: MIT](https://img.shields.io/pypi/l/pyrunnable.svg)](./LICENSE)

## Features

- Simple subclass of `threading.Thread`
- Lifecycle hooks you can override:
  - `on_start()` — called right after `start()`
  - `work()` — called repeatedly while running
  - `on_stop()` — called once after stopping
- Convenient `stop(join: bool = True)` helper

## Installation

- With pip:

```bash
pip install pyrunnable
```

- With uv (recommended):

```bash
uv add pyrunnable
```

## Quick start

```python
from time import sleep
from pyrunnable import Runnable

class Worker(Runnable):
    def on_start(self):
        print("starting")

    def work(self):
        print("working")
        sleep(0.2)

    def on_stop(self):
        print("stopping")

if __name__ == "__main__":
    w = Worker()
    try:
        w.start()
        w.join()  # Runnable inherits from threading.Thread
    except KeyboardInterrupt:
        w.stop()
```

## Compatibility

- Python: >= 3.6
- OS: Any platform supporting Python threads

## Development

This project uses [uv](https://github.com/astral-sh/uv) for building and packaging.

- Build distributions:

```bash
uv build
```

## Links

- Homepage/Repo: https://github.com/nbdy/pyrunnable
- Issues: https://github.com/nbdy/pyrunnable/issues

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyrunnable",
    "maintainer": "nbdy",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "nbdy",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/70/9c/dc8e1f8545ebfabdb8fec38adb2d74838df7d13962b73d8216c4ce203aef/pyrunnable-1.0.1.tar.gz",
    "platform": null,
    "description": "# pyrunnable\n\nLightweight convenience wrapper around `threading.Thread` with lifecycle hooks.\n\n[![PyPI](https://img.shields.io/pypi/v/pyrunnable.svg)](https://pypi.org/project/pyrunnable/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/pyrunnable.svg)](https://pypi.org/project/pyrunnable/)\n[![License: MIT](https://img.shields.io/pypi/l/pyrunnable.svg)](./LICENSE)\n\n## Features\n\n- Simple subclass of `threading.Thread`\n- Lifecycle hooks you can override:\n  - `on_start()` \u2014 called right after `start()`\n  - `work()` \u2014 called repeatedly while running\n  - `on_stop()` \u2014 called once after stopping\n- Convenient `stop(join: bool = True)` helper\n\n## Installation\n\n- With pip:\n\n```bash\npip install pyrunnable\n```\n\n- With uv (recommended):\n\n```bash\nuv add pyrunnable\n```\n\n## Quick start\n\n```python\nfrom time import sleep\nfrom pyrunnable import Runnable\n\nclass Worker(Runnable):\n    def on_start(self):\n        print(\"starting\")\n\n    def work(self):\n        print(\"working\")\n        sleep(0.2)\n\n    def on_stop(self):\n        print(\"stopping\")\n\nif __name__ == \"__main__\":\n    w = Worker()\n    try:\n        w.start()\n        w.join()  # Runnable inherits from threading.Thread\n    except KeyboardInterrupt:\n        w.stop()\n```\n\n## Compatibility\n\n- Python: >= 3.6\n- OS: Any platform supporting Python threads\n\n## Development\n\nThis project uses [uv](https://github.com/astral-sh/uv) for building and packaging.\n\n- Build distributions:\n\n```bash\nuv build\n```\n\n## Links\n\n- Homepage/Repo: https://github.com/nbdy/pyrunnable\n- Issues: https://github.com/nbdy/pyrunnable/issues\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": null,
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/nbdy/pyrunnable",
        "Issues": "https://github.com/nbdy/pyrunnable/issues",
        "Repository": "https://github.com/nbdy/pyrunnable.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1d3d5166b6970a11ee710e8c66f06be5be5eb086cf4a2048baeb033833a86348",
                "md5": "09719d66312214c984893e0fe232691e",
                "sha256": "f9e86937562ba0ed1eb9d7f034703f1164252574d448a70693682e78a8a25ace"
            },
            "downloads": -1,
            "filename": "pyrunnable-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "09719d66312214c984893e0fe232691e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 2890,
            "upload_time": "2025-10-21T22:48:14",
            "upload_time_iso_8601": "2025-10-21T22:48:14.617978Z",
            "url": "https://files.pythonhosted.org/packages/1d/3d/5166b6970a11ee710e8c66f06be5be5eb086cf4a2048baeb033833a86348/pyrunnable-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "709cdc8e1f8545ebfabdb8fec38adb2d74838df7d13962b73d8216c4ce203aef",
                "md5": "b59b53c4c860df1942575a7f6199b0f8",
                "sha256": "0345aaf1bd22ccda7db6e5863026ffff4dd727d9caea9462530ddc29d3683825"
            },
            "downloads": -1,
            "filename": "pyrunnable-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b59b53c4c860df1942575a7f6199b0f8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 2781,
            "upload_time": "2025-10-21T22:48:15",
            "upload_time_iso_8601": "2025-10-21T22:48:15.606328Z",
            "url": "https://files.pythonhosted.org/packages/70/9c/dc8e1f8545ebfabdb8fec38adb2d74838df7d13962b73d8216c4ce203aef/pyrunnable-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-21 22:48:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nbdy",
    "github_project": "pyrunnable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyrunnable"
}
        
Elapsed time: 3.10965s