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.3a1.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.3a1-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for runtime_threading-0.0.3a1.tar.gz
Algorithm Hash digest
SHA256 53d04d8adf49262c0bdc4b636e2c7822939b4206658de3c2a03e07610f8030cc
MD5 9e27ce845ea8569ae337586d432831ab
BLAKE2b-256 952169bd1234d49e99795c0c3c28d95c89360835cb0e27b881251894b04f8dc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for runtime_threading-0.0.3a1.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.3a1-py3-none-any.whl.

File metadata

File hashes

Hashes for runtime_threading-0.0.3a1-py3-none-any.whl
Algorithm Hash digest
SHA256 873e4f081f9df451192d6eecfd4c917ac3260e08d276931f205e294c6011e0a0
MD5 325ebef2e56accc6d28634a2b4356cca
BLAKE2b-256 54e18746fb0d36f3397883cc4691344c638194fdda7dac2d3da05039de5867d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for runtime_threading-0.0.3a1-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