asyncio-atexit
Like atexit, but for asyncio
Decision gist · record as of 2026-08-14
Yes, if you need event-loop-scoped cleanup in asyncio applications. Install friction is minimal and the license is permissive. The main caveat: the package has not been updated since 2022-04-26, so verify compatibility with your Python version and test that cleanup runs as expected in your specific event loop setup. No known vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Must be called from within a running event loop, and cleanup only runs if the application explicitly calls loop.close()
- Low friction: pure Python wheel with no runtime dependencies.
- Maintenance is active with recent commits, though the package itself has not been updated since 2022-04-26.
License · maintenance · safety
MIT License (permissive) — MIT License (permissive) — you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2022-04-26 (1571 days) · last repo commit 2026-07-06 · 22 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 671,892 downloads/mo, #5,403 on PyPI
Alternatives
Verify before relying
pip install asyncio-atexit
import asyncio_atexit
async def cleanup():
print('Cleaning up')
asyncio_atexit.register(cleanup)
# cleanup() runs when the event loop closes- Whether the package works correctly with modern Python versions beyond 3.6, given no release since 2022
- Behavior when multiple event loops are created in the same process
- Performance impact of the registration mechanism under high-volume cleanup scenarios
What it is and what it does
asyncio-atexit fills a gap in asyncio's lifecycle management by providing a way to register coroutines and synchronous functions that run when an event loop closes. The standard library's atexit module registers functions to run at interpreter shutdown, but asyncio applications often need cleanup tied to the event loop's lifecycle instead—for example, closing database connections or flushing buffers when a specific loop terminates. This package lets you register those handlers and have them called automatically.
The package accepts both async and sync functions, and they are invoked when loop.close() is called. It's a thin, focused tool: no dependencies, works with Python 3.6 and later, and integrates directly into asyncio's shutdown sequence. The main constraint is that cleanup only runs if your application explicitly closes the loop—it won't trigger on implicit cleanup or if the loop is abandoned.
Use it for
- Close database or cache connections when an asyncio application's event loop shuts down
- Flush pending writes or cleanup temporary resources in async server applications
- Register teardown logic in async test fixtures that need to run after each event loop
- Clean up external resources (files, network sockets) tied to a specific event loop instance
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need event-loop-scoped cleanup in asyncio applications.
Install friction is minimal and the license is permissive. The main caveat: the package has not been updated since 2022-04-26, so verify compatibility with your Python version and test that cleanup runs as expected in your specific event loop setup. No known vulnerabilities.
Install
asyncio-atexit on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is active with recent commits, though the package itself has not been updated since 2022-04-26.
Must be called from within a running event loop, and cleanup only runs if the application explicitly calls loop.close()
License in practice
MIT License (permissive) — you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install asyncio-atexit
import asyncio_atexit
async def cleanup():
print('Cleaning up')
asyncio_atexit.register(cleanup)
# cleanup() runs when the event loop closes
Verify before relying
- Whether the package works correctly with modern Python versions beyond 3.6, given no release since 2022
- Behavior when multiple event loops are created in the same process
- Performance impact of the registration mechanism under high-volume cleanup scenarios
Package facts
| License | MIT License permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 1,571 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 671,892 / month, #5,403 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: AsyncIOLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6 |
Evidence: asyncio_atexit-1.0.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “asyncio cleanup on loop close”
- asyncio-atexitRegisters cleanup functions to run when an asyncio event loop closes,…
- asyncioThis package is an obsolete backport of Python's asyncio module and…
- nest-asyncio2Patches asyncio to allow nested event loops, enabling `asyncio.run()`…
Give your agent the search over MCP, or paste the wish link into any chat.
More Application Frameworks packages
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Textual is a Python framework for building cross-platform user interfaces that run in the terminal or web browser using a modern, component-based API.
Install it if you're developing CLI tools, dashboards, or interactive terminal applications.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Build and connect to Model Context Protocol servers that expose tools, resources, and prompts to LLM applications over stdio, HTTP, or SSE transports.
Install it if you need to build or connect to servers.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
See also aiorun · async-exit-stack · asyncio · qasync · aioprocessing · syncer · asynctest · nest-asyncio2 · aiomultiprocess · aiosignal