sanic.models.asgi.MockProtocol#

class MockProtocol(transport: MockTransport, loop)

complete#

async def complete(self): -> None

drain#

async def drain(self): -> None

is_complete#

@property
def is_complete(self): -> <class 'bool'>

pause_writing#

def pause_writing(self): -> None

push_data#

async def push_data(self, data: <class 'bytes'>): -> None

resume_writing#

def resume_writing(self): -> None

sanic.models.asgi.MockTransport#

Base class for transports.

Inherits from: TransportProtocol, BaseTransport

class MockTransport(scope: typing.MutableMapping[str, typing.Any], receive: typing.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]], send: typing.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]]): -> None

add_task#

def add_task(self): -> None

close#

Close the transport.

def close(self)

Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument.

create_websocket_connection#

def create_websocket_connection(self, send: typing.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]], receive: typing.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]]): -> <class 'sanic.server.websockets.connection.WebSocketConnection'>

get_extra_info#

Get optional transport information.

def get_extra_info(self, info: <class 'str'>, default = None): -> typing.Union[str, bool, NoneType]

get_protocol#

Return the current protocol.

def get_protocol(self): -> <class 'sanic.models.asgi.MockProtocol'>

get_websocket_connection#

def get_websocket_connection(self): -> <class 'sanic.server.websockets.connection.WebSocketConnection'>

is_closing#

Return True if the transport is closing or closed.

def is_closing(self)

receive#

async def receive(self): -> typing.MutableMapping[str, typing.Any]

send#

async def send(self, data): -> None

set_protocol#

Set a new protocol.

def set_protocol(self, protocol)

sanic.models.futures.FutureException#

FutureException(handler, exceptions)

Inherits from: tuple

class FutureException(handler: typing.Callable[[~Request, BaseException], typing.Optional[typing.Coroutine[typing.Any, typing.Any, NoneType]]], exceptions: typing.List[BaseException])

sanic.models.futures.FutureListener#

FutureListener(listener, event, priority)

Inherits from: tuple

class FutureListener(listener: typing.Union[typing.Callable[[~Sanic], typing.Optional[typing.Coroutine[typing.Any, typing.Any, NoneType]]], typing.Callable[[~Sanic, asyncio.events.AbstractEventLoop], typing.Optional[typing.Coroutine[typing.Any, typing.Any, NoneType]]]], event: <class 'str'>, priority: <class 'int'>)

sanic.models.futures.FutureMiddleware#

FutureMiddleware(middleware, attach_to)

Inherits from: tuple

class FutureMiddleware(middleware: typing.Union[typing.Callable[[~Request], typing.Union[sanic.response.types.HTTPResponse, NoneType, typing.Coroutine[typing.Any, typing.Any, typing.Optional[sanic.response.types.HTTPResponse]]]], typing.Callable[[~Request, sanic.response.types.BaseHTTPResponse], typing.Union[sanic.response.types.HTTPResponse, NoneType, typing.Coroutine[typing.Any, typing.Any, typing.Optional[sanic.response.types.HTTPResponse]]]]], attach_to: <class 'str'>)

sanic.models.futures.FutureRegistry#

set() -> new empty set object

Inherits from: set

class FutureRegistry(self)

set(iterable) -> new set object

Build an unordered collection of unique elements.

sanic.models.futures.FutureRoute#

FutureRoute(handler, uri, methods, host, strict_slashes, stream, version, name, ignore_body, websocket, subprotocols, unquote, static, version_prefix, error_format, route_context)

Inherits from: tuple

class FutureRoute(handler: <class 'str'>, uri: <class 'str'>, methods: typing.Optional[typing.Iterable[str]], host: typing.Union[str, typing.List[str]], strict_slashes: <class 'bool'>, stream: <class 'bool'>, version: typing.Optional[int], name: <class 'str'>, ignore_body: <class 'bool'>, websocket: <class 'bool'>, subprotocols: typing.Optional[typing.List[str]], unquote: <class 'bool'>, static: <class 'bool'>, version_prefix: <class 'str'>, error_format: typing.Optional[str], route_context: <class 'sanic.types.hashable_dict.HashableDict'>)

sanic.models.futures.FutureSignal#

FutureSignal(handler, event, condition, exclusive, priority)

Inherits from: tuple

class FutureSignal(handler: typing.Callable[..., typing.Coroutine[typing.Any, typing.Any, NoneType]], event: <class 'str'>, condition: typing.Optional[typing.Dict[str, str]], exclusive: <class 'bool'>, priority: <class 'int'>)

sanic.models.futures.FutureStatic#

FutureStatic(uri, file_or_directory, pattern, use_modified_since, use_content_range, stream_large_files, name, host, strict_slashes, content_type, resource_type, directory_handler)

Inherits from: tuple

class FutureStatic(uri: <class 'str'>, file_or_directory: <class 'pathlib.Path'>, pattern: <class 'str'>, use_modified_since: <class 'bool'>, use_content_range: <class 'bool'>, stream_large_files: typing.Union[bool, int], name: <class 'str'>, host: typing.Optional[str], strict_slashes: typing.Optional[bool], content_type: typing.Optional[str], resource_type: typing.Optional[str], directory_handler: <class 'sanic.handlers.directory.DirectoryHandler'>)

sanic.models.http_types.Credentials#

Credentials(auth_type: 'Optional[str]', token: 'Optional[str]', _username: 'Optional[str]' = None, _password: 'Optional[str]' = None)

class Credentials(auth_type: Optional[str], token: Optional[str], _username: Optional[str] = None, _password: Optional[str] = None): -> None

password#

@property
def password(self)

username#

@property
def username(self)

sanic.models.protocol_types.HTMLProtocol#

Base class for protocol classes.

Inherits from: Protocol, Generic

class HTMLProtocol(args, kwargs)

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -&gt; int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example::

class C:
    def meth(self) -&gt; int:
        return 0

def func(x: Proto) -&gt; int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with

sanic.models.protocol_types.Range#

Base class for protocol classes.

Inherits from: Protocol, Generic

class Range(args, kwargs)

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -&gt; int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example::

class C:
    def meth(self) -&gt; int:
        return 0

def func(x: Proto) -&gt; int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with

sanic.models.protocol_types.TransportProtocol#

Base class for transports.

Inherits from: BaseTransport

class TransportProtocol(extra = None)

close#

Close the transport.

def close(self)

Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument.

get_extra_info#

Get optional transport information.

def get_extra_info(self, name, default = None)

get_protocol#

Return the current protocol.

def get_protocol(self)

is_closing#

Return True if the transport is closing or closed.

def is_closing(self)

set_protocol#

Set a new protocol.

def set_protocol(self, protocol)

sanic.models.server_types.ConnInfo#

Local and remote addresses and SSL status info.

class ConnInfo(transport: TransportProtocol, unix = None)

sanic.models.server_types.Signal#

class Signal()