aiorun
Boilerplate for asyncio applications
What it is and what it does
aiorun is a lightweight wrapper around asyncio that eliminates boilerplate for long-lived async applications. Instead of manually creating event loops, scheduling tasks, setting up signal handlers, and orchestrating graceful shutdown, you pass a coroutine to aiorun.run() and it handles the rest—creating the loop, running forever, catching SIGINT and SIGTERM, cancelling pending tasks, and closing cleanly.
The package is designed for servers and daemon-like applications that should keep running until explicitly stopped. Unlike the standard library's asyncio.run(), which exits when the coroutine completes, aiorun.run() runs indefinitely unless you call loop.stop() or an unhandled exception occurs (if stop_on_unhandled_errors=True is set). It automatically gathers and cancels all pending tasks during shutdown, waits for executor jobs to finish, and closes the event loop.
Use it for:
- Building a TCP or HTTP server that needs clean signal handling and task cancellation on shutdown.
- Running a long-lived async daemon or background worker that should survive transient errors.
- Simplifying asyncio application startup when you want to avoid writing shutdown boilerplate.
- Creating a resilient API service where one endpoint's exception shouldn't crash the entire process.
- Prototyping async applications quickly without manually managing event loop lifecycle.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a simplified entry point for asyncio applications that handles event loop setup, signal handling, task cancellation, and graceful shutdown automatically.
Yes, if you are building asyncio-based servers or long-lived applications. The package eliminates common shutdown-sequence bugs and is actively maintained with zero known vulnerabilities. Install friction is minimal (no dependencies, pure Python). The only caveat: read the documentation carefully—aiorun.run() behaves differently from asyncio.run() (runs forever by default), which can surprise developers expecting standard library semantics.
Install
aiorun on PyPI
pip
pip install aiorunuv
uv add aiorunpoetry
poetry add aiorunInstalling aiorun
Before you install
Low friction—pure Python, no runtime dependencies, and actively maintained with recent releases. Last commit was 2026-08-10 and the package supports current Python versions (3.8 through 3.12).
License in practice
Permissive license treatment means you can use this in commercial and proprietary projects without restrictive obligations.
Quickstart
import asyncio
from aiorun import run
async def main():
await asyncio.sleep(1.0)
if __name__ == '__main__':
run(main())
Requires Python 3.7 or later. Note that aiorun.run() runs forever by default—call loop.stop() inside your coroutine to exit, or pass stop_on_unhandled_errors=True to crash on exceptions.
Verify before relying
- Whether the package's signal handling behavior (SIGINT, SIGTERM) is portable across Windows and Unix-like systems.
- Performance characteristics when managing many concurrent tasks during shutdown.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 564 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 312,982/month — #7,721 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aiorun-2025.1.1-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
aiojobsaiojobs provides a scheduler for spawning and…
permissive · top 15,000 on PyPI
aiotoolsaiotools provides idiomatic asyncio utilities…
permissive · top 15,000 on PyPI
asyncio-atexitRegisters cleanup functions to run when an…
permissive · top 15,000 on PyPI
asyncio-dgramProvides simple async/await wrappers for UDP…
permissive · top 15,000 on PyPI
wait-for2Provides an alternate implementation of…
permissive · top 15,000 on PyPI
aiomonitorAdds a concurrent monitor and interactive…
permissive · top 15,000 on PyPI
aioprocessingProvides asyncio-compatible wrappers around…
permissive · top 15,000 on PyPI
aioserialProvides async/await serial port I/O using…
copyleft · top 15,000 on PyPI
clarifai-protocolProvides the protocol layer for Clarifai's…
permissive · top 15,000 on PyPI
aiodebugaiodebug provides monitoring and testing…
permissive · top 15,000 on PyPI