asgi-lifespan
Programmatic startup/shutdown of ASGI apps.
Decision gist · record as of 2026-08-14
Yes, if you test ASGI applications. It is a small, stable, permissive-licensed tool with low install friction and no known vulnerabilities. The long gap since the last release (2023-03-28) is a minor concern for new Python versions, but the repository remains active and the package is marked production/stable. Verify compatibility with your Python version before relying on it for new projects.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires an async runtime (asyncio or trio); the package auto-detects which one is in use via sniffio.
- Low friction: single pure-Python dependency (sniffio).
- Package is in production/stable status but aging—last release was 2023-03-28, over two years old.
License · maintenance · safety
MIT (permissive) — MIT license is permissive with no restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2023-03-28 (1235 days) · last repo commit 2026-02-11 · 277 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 10,518,789 downloads/mo, #1,448 on PyPI
Alternatives
Verify before relying
from asgi_lifespan import LifespanManager
async def main():
async with LifespanManager(app) as manager:
print("App started")
import asyncio
asyncio.run(main())- Whether the package works with ASGI applications beyond those mentioned in the description.
- Current compatibility with Python 3.12+ given the last release was 2023-03-28 and classifiers list only up to 3.11.
What it is and what it does
asgi-lifespan provides a LifespanManager context manager that sends ASGI lifespan events (startup and shutdown) to an ASGI application without requiring an HTTP server to be running. This is primarily useful for testing and mocking ASGI applications—you can combine it with an ASGI-capable HTTP client to send test requests into an app that has been properly initialized through its lifespan protocol.
The package automatically detects whether you are running under asyncio or trio and handles the async context accordingly. It supports configurable startup and shutdown timeouts, exposes lifespan state for use in request handling, and raises clear exceptions if the application does not support the lifespan protocol or if timeouts occur. The single runtime dependency is sniffio, keeping installation friction minimal.
Use it for
- Write tests for ASGI applications that need lifespan setup and teardown without spinning up a test server.
- Mock ASGI applications in unit tests by triggering their startup and shutdown handlers programmatically.
- Access and verify lifespan state in an ASGI app during testing via the manager's state-aware app reference.
- Test ASGI middleware and lifespan event handlers in isolation without deploying to a running server.
- Verify that an ASGI app's startup and shutdown logic executes correctly before integration testing.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you test ASGI applications.
It is a small, stable, permissive-licensed tool with low install friction and no known vulnerabilities. The long gap since the last release (2023-03-28) is a minor concern for new Python versions, but the repository remains active and the package is marked production/stable. Verify compatibility with your Python version before relying on it for new projects.
Install
asgi-lifespan on PyPI
Before you install
Low friction: single pure-Python dependency (sniffio). Package is in production/stable status but aging—last release was 2023-03-28, over two years old. Repository remains active with recent commits (2026-02-11) and no archived status, though the long gap between releases may signal maintenance is minimal rather than active.
Requires an async runtime (asyncio or trio); the package auto-detects which one is in use via sniffio.
License in practice
MIT license is permissive with no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
from asgi_lifespan import LifespanManager
async def main():
async with LifespanManager(app) as manager:
print("App started")
import asyncio
asyncio.run(main())
Verify before relying
- Whether the package works with ASGI applications beyond those mentioned in the description.
- Current compatibility with Python 3.12+ given the last release was 2023-03-28 and classifiers list only up to 3.11.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagesniffio |
| Maintenance | Aging 1,235 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,518,789 / month, #1,448 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: AsyncIOFramework :: TrioIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: asgi_lifespan-2.1.0-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 › “asgi lifespan testing”
- asgi-lifespanProgrammatically trigger ASGI application startup and shutdown events…
- mangumMangum adapts ASGI applications to run on AWS Lambda, handling events…
- fastapi-lifespan-managerProvides a lifespan manager for FastAPI that allows multiple startup…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also aiohttp-asgi-connector · async-asgi-testclient · fastapi-lifespan-manager · mangum · timing-asgi · opentelemetry-instrumentation-asgi · asgi-correlation-id · sse-starlette · a2wsgi · zope.processlifetime