Classes
StreamingHandoff
4
▼
Handoff for HTTP streaming response (more_body=True).
StreamingHandoff
4
▼
Handoff for HTTP streaming response (more_body=True).
Attributes
| Name | Type | Description |
|---|---|---|
conn |
socket.socket
|
— |
scope |
dict[str, Any]
|
— |
body |
bytes
|
— |
request_id |
str | None
|
— |
WebSocketHandoff
5
▼
Handoff for WebSocket upgrade.
WebSocketHandoff
5
▼
Handoff for WebSocket upgrade.
Attributes
| Name | Type | Description |
|---|---|---|
conn |
socket.socket
|
— |
request |
RequestReceived
|
— |
client |
tuple[str, int]
|
— |
server |
tuple[str, int]
|
— |
scope |
dict[str, Any]
|
— |
AsyncPool
8
▼
Dedicated event loop for streaming/SSE/WebSocket connections.
Accepts handoffs from SyncWorker thr…
AsyncPool
8
▼
Dedicated event loop for streaming/SSE/WebSocket connections.
Accepts handoffs from SyncWorker threads via a thread-safe queue. Wraps sockets in asyncio streams and runs the ASGI app.
Methods
set_lifespan_state
1
▼
Set the lifespan state dict shared with all requests.
set_lifespan_state
1
▼
def set_lifespan_state(self, state: dict[str, Any]) -> None
Parameters
| Name | Type | Description |
|---|---|---|
state |
— |
accept_handoff
1
▼
Accept a handoff from a SyncWorker (thread-safe).
accept_handoff
1
▼
def accept_handoff(self, handoff: HandoffRequest) -> None
Parameters
| Name | Type | Description |
|---|---|---|
handoff |
— |
run
0
▼
Run the event loop until shutdown (blocking).
run
0
▼
def run(self) -> None
Internal Methods 5 ▼
__init__
5
▼
__init__
5
▼
def __init__(self, config: ServerConfig, app: ASGIApp, *, shutdown_event: threading.Event | None = None, ssl_context: ssl.SSLContext | None = None, lifecycle_collector: LifecycleCollector | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
config |
— |
|
app |
— |
|
shutdown_event |
— |
Default:None
|
ssl_context |
— |
Default:None
|
lifecycle_collector |
— |
Default:None
|
_serve
0
▼
Event loop: process handoffs until shutdown.
async
_serve
0
▼
async def _serve(self) -> None
_handle_handoff_async
1
▼
Handle a handoff (async task).
async
_handle_handoff_async
1
▼
async def _handle_handoff_async(self, handoff: HandoffRequest) -> None
Parameters
| Name | Type | Description |
|---|---|---|
handoff |
— |
_handle_streaming_handoff
1
▼
Handle HTTP streaming handoff: wrap socket, run app from scratch.
async
_handle_streaming_handoff
1
▼
async def _handle_streaming_handoff(self, handoff: StreamingHandoff) -> None
Parameters
| Name | Type | Description |
|---|---|---|
handoff |
— |
_handle_websocket_handoff
1
▼
Handle WebSocket handoff: wrap socket, run handle_websocket.
async
_handle_websocket_handoff
1
▼
async def _handle_websocket_handoff(self, handoff: WebSocketHandoff) -> None
Parameters
| Name | Type | Description |
|---|---|---|
handoff |
— |
Functions
_create_h1_protocol
1
H1Protocol
▼
Create an HTTP/1.1 protocol handler.
_create_h1_protocol
1
H1Protocol
▼
def _create_h1_protocol(*, max_incomplete_event_size: int | None = None) -> H1Protocol
Parameters
| Name | Type | Description |
|---|---|---|
max_incomplete_event_size |
int | None |
Default:None
|
Returns
H1Protocol