--- id: aiotools version: "2.2.4" license: MIT license_treatment: permissive maintenance: active --- # aiotools — Idiomatic asyncio utilities License: permissive · Maintenance: active · Downloads: 351.7K/mo ## What it is and what it does aiotools is a collection of utilities designed to make asyncio programming more ergonomic and safer. It provides structured cancellation primitives (cancel_and_wait), async context manager decorators (@actxmgr), task lifecycle management (TaskScope), and server daemon patterns with automatic signal handling. The package targets vanilla asyncio and couples tightly with asyncio internals, making it most suitable for projects already committed to the standard library's async ecosystem. The library addresses common pain points in asyncio code: coordinating cancellation without ambiguity about whether to re-raise CancelledError, writing async context managers without boilerplate classes, managing groups of concurrent tasks that complete even when siblings fail, and launching multi-process server daemons with proper lifecycle and signal handling. It depends only on async-lru and requires Python 3.11+, keeping the dependency footprint minimal. Use it for: - Implement safe task cancellation in asyncio applications without manual CancelledError handling logic. - Build async context managers and resource cleanup patterns using the @actxmgr decorator. - Manage concurrent task groups where all tasks must run to completion unless explicitly cancelled. - Launch multi-process asyncio server daemons with automatic SIGINT/SIGTERM handling. - Create repeating async timers that can be cleanly cancelled and awaited to completion. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. aiotools provides idiomatic asyncio utilities for structured concurrency, safe task cancellation, async context managers, and server lifecycle management in Python 3.11+. Yes, if you are building asyncio applications on Python 3.11+ and want structured concurrency patterns and safer cancellation semantics. The low install friction, active maintenance, MIT license, and zero known vulnerabilities make it a solid choice. Not necessary if you are using trio, anyio, or other async frameworks, or if you prefer managing task lifecycle manually. ## Install pip install aiotools uv add aiotools poetry add aiotools ## Installing aiotools Before you install: Low install friction with a single lightweight runtime dependency (async-lru). Active maintenance with a release within the last month and consistent Python 3.11+ support. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations. Quickstart: pip install aiotools import asyncio import aiotools async def main(): task = asyncio.create_task(asyncio.sleep(1)) await aiotools.cancel_and_wait(task) asyncio.run(main()) Requires Python 3.11 or later; relies on asyncio internals so compatibility is tied to CPython versions. Verify before relying: - Whether TaskScope exception handling is suitable for production long-running servers without manual result tracking. - Performance characteristics when managing hundreds or thousands of concurrent tasks. - Compatibility with asyncio subclasses or alternative event loop implementations. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 351.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio utilities, structured concurrency, safe task cancellation, async context managers, asyncio server patterns, taskscope taskgroup, async defer cleanup, asyncio, structured-concurrency, task-management [View on SkillFed](https://skillfed.io/packages/aiotools) · [View on PyPI](https://pypi.org/project/aiotools/)