Skip to content

Getting started¤

Ever used asyncio and wished you hadn't?

tinyio is a tiny (~400 lines) event loop for Python, born out of frustration with trying to get robust error handling with asyncio. (link1, link2.)

This is an alternative for the simple use-cases, where you just need an event loop, and want to crash the whole thing if anything goes wrong. (Raising an exception in every coroutine so it can clean up its resources.)

Installation¤

pip install tinyio

Requires Python 3.11+.

Quick example¤

import tinyio

def slow_add_one(x: int):
    yield tinyio.sleep(1)
    return x + 1

def foo():
    four, five = yield [slow_add_one(3), slow_add_one(4)]
    return four, five

loop = tinyio.Loop()
out = loop.run(foo())
assert out == (4, 5)

Next steps¤

Check out the coroutines and loops page.