hypercorn.typing module#

class hypercorn.typing.ASGI2Protocol(*args, **kwargs)#

Bases: Protocol

class hypercorn.typing.ASGIVersions#

Bases: TypedDict

spec_version: str#
version: Union[Literal['2.0'], Literal['3.0']]#
class hypercorn.typing.Event(*args, **kwargs)#

Bases: Protocol

async clear() None#
is_set() bool#
async set() None#
async wait() None#
class hypercorn.typing.H2AsyncStream(*args, **kwargs)#

Bases: Protocol

async close() None#
async data_received(data: bytes) None#
async ended() None#
async handle_request(event: RequestReceived, scheme: str, client: Tuple[str, int], server: Tuple[str, int]) None#
async reset() None#
scope: dict#
class hypercorn.typing.H2SyncStream(*args, **kwargs)#

Bases: Protocol

close() None#
data_received(data: bytes) None#
ended() None#
async handle_request(event: RequestReceived, scheme: str, client: Tuple[str, int], server: Tuple[str, int]) None#
reset() None#
scope: dict#
class hypercorn.typing.HTTPDisconnectEvent#

Bases: TypedDict

type: Literal['http.disconnect']#
class hypercorn.typing.HTTPEarlyHintEvent#

Bases: TypedDict

type: Literal['http.response.early_hint']#
class hypercorn.typing.HTTPRequestEvent#

Bases: TypedDict

body: bytes#
more_body: bool#
type: Literal['http.request']#
class hypercorn.typing.HTTPResponseBodyEvent#

Bases: TypedDict

body: bytes#
more_body: bool#
type: Literal['http.response.body']#
class hypercorn.typing.HTTPResponseStartEvent#

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]#
status: int#
type: Literal['http.response.start']#
class hypercorn.typing.HTTPScope#

Bases: TypedDict

asgi: ASGIVersions#
client: Optional[Tuple[str, int]]#
extensions: Dict[str, dict]#
headers: Iterable[Tuple[bytes, bytes]]#
http_version: str#
method: str#
path: str#
query_string: bytes#
raw_path: bytes#
root_path: str#
scheme: str#
server: Optional[Tuple[str, Optional[int]]]#
type: Literal['http']#
class hypercorn.typing.HTTPServerPushEvent#

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]#
path: str#
type: Literal['http.response.push']#
class hypercorn.typing.LifespanScope#

Bases: TypedDict

asgi: ASGIVersions#
type: Literal['lifespan']#
class hypercorn.typing.LifespanShutdownCompleteEvent#

Bases: TypedDict

type: Literal['lifespan.shutdown.complete']#
class hypercorn.typing.LifespanShutdownEvent#

Bases: TypedDict

type: Literal['lifespan.shutdown']#
class hypercorn.typing.LifespanShutdownFailedEvent#

Bases: TypedDict

message: str#
type: Literal['lifespan.shutdown.failed']#
class hypercorn.typing.LifespanStartupCompleteEvent#

Bases: TypedDict

type: Literal['lifespan.startup.complete']#
class hypercorn.typing.LifespanStartupEvent#

Bases: TypedDict

type: Literal['lifespan.startup']#
class hypercorn.typing.LifespanStartupFailedEvent#

Bases: TypedDict

message: str#
type: Literal['lifespan.startup.failed']#
class hypercorn.typing.ResponseSummary#

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]#
status: int#
class hypercorn.typing.TaskGroup(*args, **kwargs)#

Bases: Protocol

spawn(func: Callable, *args: Any) None#
async spawn_app(app: Union[Type[ASGI2Protocol], Callable[[Union[HTTPScope, WebsocketScope, LifespanScope], Callable[[], Awaitable[Union[HTTPRequestEvent, HTTPDisconnectEvent, WebsocketConnectEvent, WebsocketReceiveEvent, WebsocketDisconnectEvent, LifespanStartupEvent, LifespanShutdownEvent]]], Callable[[Union[HTTPResponseStartEvent, HTTPResponseBodyEvent, HTTPServerPushEvent, HTTPEarlyHintEvent, HTTPDisconnectEvent, WebsocketAcceptEvent, WebsocketSendEvent, WebsocketResponseStartEvent, WebsocketResponseBodyEvent, WebsocketCloseEvent, LifespanStartupCompleteEvent, LifespanStartupFailedEvent, LifespanShutdownCompleteEvent, LifespanShutdownFailedEvent]], Awaitable[None]]], Awaitable[None]]], config: Config, scope: Union[HTTPScope, WebsocketScope, LifespanScope], send: Callable[[Optional[Union[HTTPResponseStartEvent, HTTPResponseBodyEvent, HTTPServerPushEvent, HTTPEarlyHintEvent, HTTPDisconnectEvent, WebsocketAcceptEvent, WebsocketSendEvent, WebsocketResponseStartEvent, WebsocketResponseBodyEvent, WebsocketCloseEvent, LifespanStartupCompleteEvent, LifespanStartupFailedEvent, LifespanShutdownCompleteEvent, LifespanShutdownFailedEvent]]], Awaitable[None]]) Callable[[Union[HTTPRequestEvent, HTTPDisconnectEvent, WebsocketConnectEvent, WebsocketReceiveEvent, WebsocketDisconnectEvent, LifespanStartupEvent, LifespanShutdownEvent]], Awaitable[None]]#
class hypercorn.typing.WebsocketAcceptEvent#

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]#
subprotocol: Optional[str]#
type: Literal['websocket.accept']#
class hypercorn.typing.WebsocketCloseEvent#

Bases: TypedDict

code: int#
reason: Optional[str]#
type: Literal['websocket.close']#
class hypercorn.typing.WebsocketConnectEvent#

Bases: TypedDict

type: Literal['websocket.connect']#
class hypercorn.typing.WebsocketDisconnectEvent#

Bases: TypedDict

code: int#
type: Literal['websocket.disconnect']#
class hypercorn.typing.WebsocketReceiveEvent#

Bases: TypedDict

bytes: Optional[bytes]#
text: Optional[str]#
type: Literal['websocket.receive']#
class hypercorn.typing.WebsocketResponseBodyEvent#

Bases: TypedDict

body: bytes#
more_body: bool#
type: Literal['websocket.http.response.body']#
class hypercorn.typing.WebsocketResponseStartEvent#

Bases: TypedDict

headers: Iterable[Tuple[bytes, bytes]]#
status: int#
type: Literal['websocket.http.response.start']#
class hypercorn.typing.WebsocketScope#

Bases: TypedDict

asgi: ASGIVersions#
client: Optional[Tuple[str, int]]#
extensions: Dict[str, dict]#
headers: Iterable[Tuple[bytes, bytes]]#
http_version: str#
path: str#
query_string: bytes#
raw_path: bytes#
root_path: str#
scheme: str#
server: Optional[Tuple[str, Optional[int]]]#
subprotocols: Iterable[str]#
type: Literal['websocket']#
class hypercorn.typing.WebsocketSendEvent#

Bases: TypedDict

bytes: Optional[bytes]#
text: Optional[str]#
type: Literal['websocket.send']#
class hypercorn.typing.WorkerContext(*args, **kwargs)#

Bases: Protocol

event_class: Type[Event]#
async static sleep(wait: Union[float, int]) None#
terminated: Event#
static time() float#