asgi-cc
asgi-cc is a Python Cranker connector for ASGI applications. It connects an ASGI app to a Cranker router over WebSocket and forwards HTTP traffic through the Cranker v3 protocol without adding a loopback HTTP hop inside the service process.
Features
- ASGI-native request and response bridging
- Cranker v3 (
cranker_3.0) protocol support - FastAPI-compatible integration
- DNS-based router discovery
- Optional suppression for
asgi-ccandwebsocketslogs - Runtime app attach and detach support
Requirements
- Python
3.11+
Installation
pip install asgi-cc
Basic Usage
Create the connector with the application and let the app lifecycle manage the connector:
import os
from fastapi import FastAPI
from asgi_cc import CrankerConnector, CrankerConnectorConfig
app = FastAPI()
@app.get("/hello")
async def hello() -> dict[str, str]:
return {"message": "hello through cranker"}
connector = CrankerConnector(
app,
CrankerConnectorConfig(
router_urls=[os.environ.get("CRANKER_ROUTER_URL", "wss://localhost:12001")],
route="*",
verify_ssl=False,
component_name="my-service",
),
)
Keep using app as the ASGI server entrypoint. The connector composes with the app's existing lifespan: it starts after application setup and shuts down before application cleanup. Custom lifespan state is preserved.
Middleware Usage
import os
from fastapi import FastAPI
from asgi_cc import CrankerConnector, CrankerConnectorConfig
app = FastAPI()
app.add_middleware(
CrankerConnector,
config=CrankerConnectorConfig(
router_urls=[os.environ.get("CRANKER_ROUTER_URL", "wss://localhost:12001")],
route="*",
verify_ssl=False,
component_name="my-service",
),
)
Runtime App Management
connector = CrankerConnector(config=config)
await connector.attach(app)
await connector.detach()
If the connector is started without an attached app, incoming requests receive 503 Service Unavailable until an app is attached.
Router Discovery
config = CrankerConnectorConfig(
router_urls=["wss://router.example.org"],
route="*",
router_lookup_by_dns=True,
router_update_interval_seconds=60,
)
When enabled, asgi-cc resolves router hostnames to IP addresses, opens registrations for the currently resolved routers, and periodically reconciles router registrations as DNS changes.
Logging
Set disable_logging=True to suppress logs emitted by asgi-cc and the underlying websockets package:
config = CrankerConnectorConfig(
router_urls=["wss://router.example.org"],
route="*",
disable_logging=True,
)
Project Links
Metadata
Release files for asgi-cc 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asgi_cc-0.2.0.tar.gz | 15.3 kB | With provenance | Details for asgi_cc-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asgi_cc-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for asgi_cc-0.2.0-py3-none-any.whl |
Total release size: 28.0 kB
Release files / asgi_cc-0.2.0.tar.gz
| Download URL | asgi_cc-0.2.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66c6332ad3535b826c2baa76c415d19293a7d934024636f9d1b77e4c1e13cd29
|
|
BLAKE2b-256 checksum How to use checksums |
0806064d2cea2c336db234ef38996c319ae560dfc8b59b53c9ea32346901d8cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / asgi_cc-0.2.0-py3-none-any.whl
| Download URL | asgi_cc-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f3bd52467490c46746c4bf4b28d66eb69af45f596256707a75ab55d05d7a629
|
|
BLAKE2b-256 checksum How to use checksums |
c97c2b7a850156958f98efef228f7b09877e30efbf3d611a3b246c1ab9971d1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for asgi-cc 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for asgi_cc-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.