Skip to main content

loopmini

A boring, maintainable, drop-in event loop for asyncio applications on Linux and Mac. It tracks CPython, stays sound under Ctrl-C, and shares its reactor with Rust.

import asyncio, loopmini

async def main():
    await asyncio.sleep(0.1)
    return await asyncio.to_thread(lambda: 42)

asyncio.run(main(), loop_factory=loopmini.new_event_loop)

Install

pip install loopmini

Design

The Python side subclasses asyncio.BaseEventLoop and reuses its task, future, executor, error-handling, networking, server, sendfile, and subprocess machinery. Reactor-neutral socket, Unix, pipe, and accept implementations come directly from CPython's selector loop. Loopmini supplies the scheduling and fd-readiness hooks plus socket and datagram transports, so version-sensitive asyncio behavior remains CPython's own.

The Rust side owns fd readiness, timers, and cross-thread wakeup through a small level-triggered reactor core (polling, using kqueue/epoll). The Python driver blocks directly in the reactor with the GIL released. The same PyO3-free core is available to Rust consumers; embedding runtimes can run futures on their own workers and wake the Python loop through its thread-safe scheduling path.

Compatibility

Four external test suites act as conformance oracles, run with pytest -m oracle: CPython's own test_asyncio, and the suites of anyio, uvloop, and aiohttp, about 7,000 tests in all. All four pass. The few exclusions are listed with reasons in tests/test_oracle.py.

Interrupts

A KeyboardInterrupt injected while the loop runs (the kernel interrupt mechanism, and the delivery path of Ctrl-C) leaves the loop in a resumable state. Each scheduled callback either runs or remains queued. The standard loop can lose the callback in the same situation. The test suite injects interrupts under stream, timer, and cross-thread load to hold this guarantee, and the loop must keep serving afterwards.

Performance

Throughput matches the standard loop on real I/O workloads. A 30-second soak serving a fasthtml app under concurrent HTTP and websocket load holds a 2.6ms median response with no fd or memory growth. There is a small overhead involved in getting the better interrupt semantics, due to having to cross the Rust boundary. It applies only when something is scheduled onto the loop, and is then under 1µs per operation: create_task, an await that suspends, asyncio.sleep, or call_soon. Code that stays inside Python, including an await that does not suspend, pays nothing. The median overshoot of a 1ms timer is ~0.2ms, similar to Python's standard loop.

Download files

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

Source Distribution

loopmini-0.2.2.tar.gz (35.4 kB view details)

Uploaded Source

Built Distributions

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

loopmini-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

loopmini-0.2.2-cp314-cp314-macosx_11_0_arm64.whl (275.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

loopmini-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

loopmini-0.2.2-cp313-cp313-macosx_11_0_arm64.whl (273.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

loopmini-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

loopmini-0.2.2-cp312-cp312-macosx_11_0_arm64.whl (274.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

loopmini-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

loopmini-0.2.2-cp311-cp311-macosx_11_0_arm64.whl (279.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file loopmini-0.2.2.tar.gz.

File metadata

  • Download URL: loopmini-0.2.2.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for loopmini-0.2.2.tar.gz
Algorithm Hash digest
SHA256 46fd64daf85f63034250f0af597c476c9b2b8d9ae561810ad88dac4724065522
MD5 9465c294938f8b30eaf6fe15622ee563
BLAKE2b-256 90f701813442aeb7bb8ce1b4fb1af901dad7bb551c3c82c166a5d1f57d613103

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2.tar.gz:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b837cb9b8c32ad9d03b2895b4c859eab4aac6dd2a47fd235a6561551a2eb29d
MD5 d1c6da300e1d874af7e18e8f27d91b8f
BLAKE2b-256 64a0b466abc435532440b0286321d1c543241ca363dab8d880fda512f5d986f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c51ad0dab6ddd868b7c92979d7e97b585712e4c3c552a0931233086370a314d
MD5 5ff3f8ef1dec4fdcf5b167cf588dc38e
BLAKE2b-256 acdbe0a980a9785e6364f851714a71dd07956a88b94dd11bc521a877db657ed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 621799900adad50c95ea4387ebc6bcfc2ca18124d7af93e7425948ccc442b967
MD5 d33c7205aa15ab7e2e058a6d6c297604
BLAKE2b-256 9fa1b4452ac463c000bfb04f3c88b3e5889f03787923f8b24657efb01f91c7f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f23bdfd01af08be0f70b5bedee7e420ac7db61fa70b61606a34baa259c677a8c
MD5 7e53d7ad5313ade81cfec30694b67947
BLAKE2b-256 0232465f3ffaed83b5b2abb4799250d894de224809859ee79dbc7f83a2f7ae52

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d35853a74a4fa6380ab8df62fb4ba0e9c1069203ad1714e34db76a56ed2e9718
MD5 74fe2186383f1e007d24c558f5896d25
BLAKE2b-256 8f80334c122b4f0f87dba3b6809a9633752998ce59df4df49f667234d533c205

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 568715957356f53866ae5d5b38e887437d7af3bd37b88d58d681d359d897df7c
MD5 914bef44cb4f2de014468c2be04bed5b
BLAKE2b-256 756206d3b6e78c271932dbe63901df1cacc027b5ec11c6c1b6a2ad2beca63c2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4cd87b766682db8ddfb6e063ab7c990ecff3d3eee2a4aa6e5f131edc4385977f
MD5 49fb3617b3700f88b8174f07d3ef082c
BLAKE2b-256 34451bfc7d724243c8a94f76407ecb030105f548efbb83444ce8f2f0ecd3bbaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

File details

Details for the file loopmini-0.2.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 130cb1395dc20ee1017f4d2571c1d2f4857f439f9b024120d5b241df49f8aef6
MD5 855a5ff744e18f3ce07256a7b25e50cd
BLAKE2b-256 85e898633ed0d67bf74f57d31edb0c5f6e69a6e606988f5b768c815c2f9f1ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on AnswerDotAI/loopmini

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

Release history Release notifications | RSS feed

This release

0.2.2 This release

9 files

0.2.1

9 files

0.1.1

9 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