Skip to main content

Provides a task based abstraction to threading.

Project description

Test Coverage Stable Version Pre-release Version PyPI - Python Version PyPI Downloads

runtime-threading

This project provides a task based abstraction to threading.

Example

from runtime.threading import InterruptSignal, InterruptException
from runtime.threading.tasks import Task, ContinuationOptions

try:
     signal = InterruptSignal()
     i = 227
     m = 0.78

     def fn(task: Task[float], i: float, m: float) -> float:
          task.interrupt.raise_if_signaled()
          return i * m

     def fn_continue(task: Task[float], preceding_task: Task[float], m: float) -> float:
          return preceding_task.result * m

     task1 = Task.run(fn, i, m)
     task2 = task1.continue_with(ContinuationOptions.ON_COMPLETED_SUCCESSFULLY, fn_continue, m)

     result1 = task1.result # -> 177.06
     result2 = task2.result # -> 138.1068

     task3 = Task.create(interrupt = signal.interrupt, lazy = True).plan(fn, task1.result, m)

     signal.signal()

     # task3 is run lazily when result property is accessed
     result3 = task3.result # TaskInterruptedException

except InterruptException:
     pass # won't happen since the interrupt is never signaled

Full documentation

Go to documentation

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

runtime_threading-0.0.3.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

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

runtime_threading-0.0.3-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

Details for the file runtime_threading-0.0.3.tar.gz.

File metadata

  • Download URL: runtime_threading-0.0.3.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for runtime_threading-0.0.3.tar.gz
Algorithm Hash digest
SHA256 37164680bf556179c3dd25c9caa36690e6af0bd523b1025a3d87ee26e5af144b
MD5 3d5288bb178c1ea93780eeeefe6f4e22
BLAKE2b-256 b50bc68528da595cbc67829467fe0b674dd54dce78d81d364966e0b4263650fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for runtime_threading-0.0.3.tar.gz:

Publisher: python-publish.yml on apmadsen/runtime-threading

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

File details

Details for the file runtime_threading-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for runtime_threading-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 240262875c08d0b02c082bcfaa67df40b9e60b2083bebfd8e9596e4f09d0da9f
MD5 8d2d38afb80b5f92e272d0b9dae6da86
BLAKE2b-256 0b013405c7b598a740bacadcedbd8a8a224a36d4373863c875cdbcf7eec7c56f

See more details on using hashes here.

Provenance

The following attestation bundles were made for runtime_threading-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on apmadsen/runtime-threading

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