Registry / http-networking / aiohttp-asgi-connector

aiohttp-asgi-connector

JSON →
library1.1.2pypypi✓ verified 80d ago

Provides an aiohttp connector for running ASGI applications (e.g., Starlette, FastAPI) inside an aiohttp test harness or client without needing a live server. Current version 1.1.2, supports Python >=3.8, maintained on GitHub.

pip install aiohttp-asgi-connector
INSTALL
IMPORT
SIG · AIOHTTP-ASGI-CONNE
A
aiohttp-asgi-connector
http-networkingpythonv1.1.2
Install
3.9s avg
Import
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.000s · 29MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ASGIApplicationConnector
from aiohttp_asgi_connector import ASGIApplicationConnector
from aiohttp_asgi_connector import ASGIConnector

Creates an aiohttp connector that wraps an ASGI app for in-process testing.

import asyncio import aiohttp from aiohttp_asgi_connector import ASGIConnector from starlette.applications import Starlette from starlette.responses import PlainTextResponse async def test(): app = Starlette() async def homepage(request): return PlainTextResponse('Hello, World!') app.add_route('/', homepage) connector = ASGIConnector(app) async with aiohttp.ClientSession(connector=connector) as session: async with session.get('http://testserver/') as resp: print(await resp.text()) asyncio.run(test())
Debug
Known issues
gotchaThe ASGI app must have a lifespan handler. If the app does not implement lifespan events (startup/shutdown), you may need to pass 'lifespan=False' to ASGIConnector.
fix
connector = ASGIConnector(app, lifespan=False)
affects: all
gotchaThe connector automatically adds a 'testserver' host header. If your ASGI app validates the Host header, ensure it matches 'testserver' or disable host checking.
fix
Override the Host header in your aiohttp request or configure the ASGI app accordingly.
affects: all
deprecatedOlder versions required importing from 'aiohttp_asgi' (note: singular 'asgi'). The package name changed to 'aiohttp-asgi-connector' and import path to 'aiohttp_asgi_connector'.
fix
Update install and import to 'aiohttp-asgi-connector' and 'from aiohttp_asgi_connector import ASGIConnector'.
affects: <1.0.0
Upgrade
Version history
1.1.2latest on PyPI · released Jun 22, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
44 hits · last 30 days
node
36
OpenAI (training)
1
Resources
aiohttp-asgi-connector — pip install aiohttp-asgi-connector · libregistry