Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

tealetio

tealetio: async without the async.

Where tealet gives you stack-slicing primitives, tealetio turns them into a runtime framework with a familiar shape. It adds scheduler, task, synchronisation, selector, runner, and asyncio coexistence APIs for ordinary tealet code.

In effect, async operations can work without the async keyword: tealet-powered stack slicing lets ordinary-looking functions block, resume, and compose through the scheduler.

The top-level package is meant to feel direct: import the common classes and helpers from tealetio, just as you would from asyncio. Submodules remain available when you want to name the implementation home explicitly.

from tealetio import Event, Scheduler, gather, run, wait_for

Installation

For the usual scheduler and synchronisation APIs, install the base package:

python -m pip install tealetio

Need to run async methods efficiently from tealetio? Install the optional asyncio extra. It pulls in asynkit, which tealetio uses to optimise the asyncio bridge where available:

python -m pip install 'tealetio[asyncio]'

Quick Start

Need a scheduler for synchronous tealet code? Use run() and ask for the running scheduler inside your entry point:

from tealetio import Event, get_running_scheduler, run


def main() -> str:
    scheduler = get_running_scheduler()
    event = Event()
    seen: list[str] = []

    def worker() -> None:
        seen.append("waiting")
        event.swait()
        seen.append("done")

    task = scheduler.spawn(worker)
    scheduler.call_soon(event.set)
    task.wait()
    return ", ".join(seen)


assert run(main) == "waiting, done"

Already inside an asyncio program? Use AsyncRunner to host tealet work without leaving the asyncio world:

import asyncio

from tealetio import AsyncRunner, Event, get_running_scheduler


async def main() -> list[str]:
    async with AsyncRunner() as runner:
        def entry() -> list[str]:
            scheduler = get_running_scheduler()
            event = Event()
            seen: list[str] = []

            def worker() -> None:
                seen.append("waiting")
                event.swait()
                seen.append("done")

            task = scheduler.spawn(worker)
            scheduler.call_soon(event.set)
            task.wait()
            return seen

        return await runner.run(entry)


assert asyncio.run(main()) == ["waiting", "done"]

Public API

The common API is available directly from tealetio:

  • schedulers and runners: Scheduler, SelectorScheduler, AsyncScheduler, Runner, AsyncRunner, run, run_async
  • tasks and futures: Future, Task, spawn, create_task, get_current, CancelledError, shield
  • wait helpers: gather, wait, wait_for, as_completed, ensure_future, to_thread
  • synchronisation primitives: Event, Lock, Semaphore, Condition, Barrier, Queue
  • rendezvous communication: Channel
  • asyncio coexistence helpers: asyncio_get_current, run_in_asyncio, run_asyncio_in_tealet, TealetSelectorEventLoop

If you prefer explicit homes, submodules such as tealetio.scheduler, tealetio.tasks, tealetio.locks, tealetio.runner, tealetio.selector, and tealetio.asyncio define the same objects.

Asyncio Model

The design intentionally follows asyncio where the mapping is useful. In effect, you already know much of the shape: the learning curve stays small, and interop with asyncio-hosted programs stays straightforward. Some names differ to match tealet execution: Scheduler fills the role normally held by an event loop, and spawn(...) is the native tealet-facing equivalent of create_task(...). The package root also exports create_task(...) as a familiar alias.

Synchronisation primitives are asyncio-compatible where practical and add s-prefixed methods for tealet-blocking operations, such as Event.swait(), Lock.sacquire(), and Queue.sget(). tealetio also reuses asyncio exceptions where that preserves familiar behaviour and compatibility.

Channel is inspired by Stackless Python channels. It provides rendezvous-style communication between tasks, with selectable sender/receiver preference models, and can also be used for inter-thread communication through scheduler-safe wakeup paths.

Notice one important runtime difference: exception delivery. Exceptions such as CancelledError are delivered immediately by switching to the target tealet, instead of being kept as pending exceptions. This avoids races where multiple pending exceptions can accumulate, and removes the need to track pending cancellations separately. These deviations are intentional, but the exact API shape remains subject to change before a stable release.

Status

tealetio is pre-1.0 software. APIs are usable for experimentation and in-repo testing, but may change before a stable release.

Documentation

Metadata

Release files for tealetio 0.1.0rc1

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

Source distribution (sdist)

Source distribution for tealetio 0.1.0rc1
File Size Uploaded
tealetio-0.1.0rc1.tar.gz 31.4 kB Details

Built distribution (wheel)

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

Total release size: 67.3 kB

Release files / tealetio-0.1.0rc1.tar.gz

Download URL tealetio-0.1.0rc1.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
85b4468a86a744b5117e40d4904f75e8f8a9c2fafa0337f8755738d4f343ed0e
BLAKE2b-256 checksum
How to use checksums
c69844cd9b11a58b426e381e05856e29427c39ba0baba20342c64be4ae7de56f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 25, 2026.

Transparency log

Release files / tealetio-0.1.0rc1-py3-none-any.whl

Download URL tealetio-0.1.0rc1-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a069440f2938e009abd7f40bee4bdf809b9b3f5c8698a23cd8ad201c6913e576
BLAKE2b-256 checksum
How to use checksums
29c29e48e8f0dd7b918cf1607af0e852024750f4c009e7205b18394429de26d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0rc1 This release

2 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