Skip to main content

No project description provided

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrunnable-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrunnable-1.0.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file pyrunnable-1.0.1.tar.gz.

File metadata

  • Download URL: pyrunnable-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrunnable-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0345aaf1bd22ccda7db6e5863026ffff4dd727d9caea9462530ddc29d3683825
MD5 b59b53c4c860df1942575a7f6199b0f8
BLAKE2b-256 709cdc8e1f8545ebfabdb8fec38adb2d74838df7d13962b73d8216c4ce203aef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrunnable-1.0.1.tar.gz:

Publisher: publish.yml on nbdy/pyrunnable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrunnable-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyrunnable-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrunnable-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9e86937562ba0ed1eb9d7f034703f1164252574d448a70693682e78a8a25ace
MD5 09719d66312214c984893e0fe232691e
BLAKE2b-256 1d3d5166b6970a11ee710e8c66f06be5be5eb086cf4a2048baeb033833a86348

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrunnable-1.0.1-py3-none-any.whl:

Publisher: publish.yml on nbdy/pyrunnable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page