Skip to main content

pyrunnable

Lightweight convenience wrapper around threading.Thread with lifecycle hooks.

PyPI Python Versions License: MIT

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:
pip install pyrunnable
  • With uv (recommended):
uv add pyrunnable

Quick start

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 for building and packaging.

  • Build distributions:
uv build

Links

Metadata

Release files for pyrunnable 1.0.1

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

Source distribution (sdist)

Source distribution for pyrunnable 1.0.1
File Size Uploaded
pyrunnable-1.0.1.tar.gz 2.8 kB Details

Built distribution (wheel)

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

Total release size: 5.7 kB

Release files / pyrunnable-1.0.1.tar.gz

Download URL pyrunnable-1.0.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0345aaf1bd22ccda7db6e5863026ffff4dd727d9caea9462530ddc29d3683825
BLAKE2b-256 checksum
How to use checksums
709cdc8e1f8545ebfabdb8fec38adb2d74838df7d13962b73d8216c4ce203aef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.

Transparency log

Release files / pyrunnable-1.0.1-py3-none-any.whl

Download URL pyrunnable-1.0.1-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9e86937562ba0ed1eb9d7f034703f1164252574d448a70693682e78a8a25ace
BLAKE2b-256 checksum
How to use checksums
1d3d5166b6970a11ee710e8c66f06be5be5eb086cf4a2048baeb033833a86348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

1 release file

0.42

3 release files

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