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.1.tar.gz (35.3 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.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

loopmini-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

loopmini-0.2.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (274.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

loopmini-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

loopmini-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: loopmini-0.2.1.tar.gz
  • Upload date:
  • Size: 35.3 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.1.tar.gz
Algorithm Hash digest
SHA256 e1b5254af6ebeec4b78e12e344e19511c0c0b43a5f6d31100269af73ab432385
MD5 dd187223f4c812ede07dce949cd100a9
BLAKE2b-256 a78382a0c0459bff9f3ed5eefb6c47d439d33df9ae3a6c256592606a5223d909

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1.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.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eeaa6b79535a4a2bba16b114f5d9ebd662ad75a33b9a2eb289df3af5491426da
MD5 b76d2ba373a686353f682c0e2ae1bdbc
BLAKE2b-256 909858a5be53b356193e7631e9b512afacacec81858cd9da04c63241736f9ded

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5f63b844114028803ccd9c7fd627705dfb51708c18fe557d4ebcb5091dc4397
MD5 e0fc97d10a7f4fce399ceb4dfea70548
BLAKE2b-256 39617cb30c539570189f96ea40b61b5078d50560bec272214e3f1ebf9769e595

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 928a9c2fba5d0e62db6b15e976bd9af9f0c9e285913ab8a66392289e66d16dc0
MD5 2d77b7ca6565c0c197f52b6607a4cd9a
BLAKE2b-256 2b8d2a849a337dc5599f78ffa74764e857fb9d47ef303c8d90bc8ac3ead7fccf

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ec86d3593a8840c08ebab3f0dac25fcabeed3305e9ef7d52ae30053d3174a1d
MD5 a387f2aa3485aadb023e9a1e70ff7d53
BLAKE2b-256 9bcb259749296eb8c727c982a8557253b4d5acdd15fc51c5591071d89b66702a

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e918cd7faae3af5cb2fff5d384bf322062a22497d99696d3ec6a75650c85ca6d
MD5 8cd6c904326d56ffa5f69796b8932875
BLAKE2b-256 8e1aa427043abd5a4ea01ff511eb82199f0589ba22c61b20491c09bd603d1bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b426c5f11e0c861d320acf7e72aafce8b1dda15d0fbe4b5018befc2b6fe3718c
MD5 79d31e518914e10b5de9d2291ae576e5
BLAKE2b-256 480d5180fe5796f45392752c2c66619f1357c50e36f28f43c1f6360537a7ba24

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5a6807be2120bba9e668cebc4c32dec2b611c5c7af21f2748f9c6fa7aa297ded
MD5 a12e92300b86fadefc39a7165d7407a8
BLAKE2b-256 a3e2daa903f785eed07396c80b4f60a54971680168136443f573782f05a9e27d

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for loopmini-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b79ea2a332efa94c58155fb480131e7012c033f299e831f7ff0a0146470eff4
MD5 9b50a5a2c1dfa323197a7c2631a603f7
BLAKE2b-256 e6341e06971796ebae40b6bd5628c499a5ab0bc2da5a5fab4241096d04c8d25f

See more details on using hashes here.

Provenance

The following attestation bundles were made for loopmini-0.2.1-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

0.2.2

9 files

This release

0.2.1 This release

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