Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -5,25 +5,13 @@ import socket
|
|||
import sys
|
||||
import warnings
|
||||
from argparse import ArgumentParser
|
||||
from collections.abc import Iterable
|
||||
from collections.abc import Awaitable, Callable, Iterable, Iterable as TypingIterable
|
||||
from contextlib import suppress
|
||||
from importlib import import_module
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
Iterable as TypingIterable,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Type,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from .abc import AbstractAccessLogger
|
||||
from .helpers import AppKey as AppKey
|
||||
from .helpers import AppKey, RequestKey, ResponseKey
|
||||
from .log import access_logger
|
||||
from .typedefs import PathLike
|
||||
from .web_app import Application as Application, CleanupError as CleanupError
|
||||
|
|
@ -108,6 +96,7 @@ from .web_response import (
|
|||
ContentCoding as ContentCoding,
|
||||
Response as Response,
|
||||
StreamResponse as StreamResponse,
|
||||
json_bytes_response as json_bytes_response,
|
||||
json_response as json_response,
|
||||
)
|
||||
from .web_routedef import (
|
||||
|
|
@ -235,11 +224,14 @@ __all__ = (
|
|||
"BaseRequest",
|
||||
"FileField",
|
||||
"Request",
|
||||
"RequestKey",
|
||||
# web_response
|
||||
"ContentCoding",
|
||||
"Response",
|
||||
"StreamResponse",
|
||||
"json_bytes_response",
|
||||
"json_response",
|
||||
"ResponseKey",
|
||||
# web_routedef
|
||||
"AbstractRouteDef",
|
||||
"RouteDef",
|
||||
|
|
@ -303,17 +295,17 @@ HostSequence = TypingIterable[str]
|
|||
|
||||
|
||||
async def _run_app(
|
||||
app: Union[Application, Awaitable[Application]],
|
||||
app: Application | Awaitable[Application],
|
||||
*,
|
||||
host: Optional[Union[str, HostSequence]] = None,
|
||||
port: Optional[int] = None,
|
||||
path: Union[PathLike, TypingIterable[PathLike], None] = None,
|
||||
sock: Optional[Union[socket.socket, TypingIterable[socket.socket]]] = None,
|
||||
ssl_context: Optional[SSLContext] = None,
|
||||
print: Optional[Callable[..., None]] = print,
|
||||
host: str | HostSequence | None = None,
|
||||
port: int | None = None,
|
||||
path: PathLike | TypingIterable[PathLike] | None = None,
|
||||
sock: socket.socket | TypingIterable[socket.socket] | None = None,
|
||||
ssl_context: SSLContext | None = None,
|
||||
print: Callable[..., None] | None = print,
|
||||
backlog: int = 128,
|
||||
reuse_address: Optional[bool] = None,
|
||||
reuse_port: Optional[bool] = None,
|
||||
reuse_address: bool | None = None,
|
||||
reuse_port: bool | None = None,
|
||||
**kwargs: Any, # TODO(PY311): Use Unpack
|
||||
) -> None:
|
||||
# An internal function to actually do all dirty job for application running
|
||||
|
|
@ -326,7 +318,7 @@ async def _run_app(
|
|||
|
||||
await runner.setup()
|
||||
|
||||
sites: List[BaseSite] = []
|
||||
sites: list[BaseSite] = []
|
||||
|
||||
try:
|
||||
if host is not None:
|
||||
|
|
@ -426,7 +418,7 @@ async def _run_app(
|
|||
|
||||
|
||||
def _cancel_tasks(
|
||||
to_cancel: Set["asyncio.Task[Any]"], loop: asyncio.AbstractEventLoop
|
||||
to_cancel: set["asyncio.Task[Any]"], loop: asyncio.AbstractEventLoop
|
||||
) -> None:
|
||||
if not to_cancel:
|
||||
return
|
||||
|
|
@ -450,25 +442,25 @@ def _cancel_tasks(
|
|||
|
||||
|
||||
def run_app(
|
||||
app: Union[Application, Awaitable[Application]],
|
||||
app: Application | Awaitable[Application],
|
||||
*,
|
||||
host: Optional[Union[str, HostSequence]] = None,
|
||||
port: Optional[int] = None,
|
||||
path: Union[PathLike, TypingIterable[PathLike], None] = None,
|
||||
sock: Optional[Union[socket.socket, TypingIterable[socket.socket]]] = None,
|
||||
host: str | HostSequence | None = None,
|
||||
port: int | None = None,
|
||||
path: PathLike | TypingIterable[PathLike] | None = None,
|
||||
sock: socket.socket | TypingIterable[socket.socket] | None = None,
|
||||
shutdown_timeout: float = 60.0,
|
||||
keepalive_timeout: float = 75.0,
|
||||
ssl_context: Optional[SSLContext] = None,
|
||||
print: Optional[Callable[..., None]] = print,
|
||||
ssl_context: SSLContext | None = None,
|
||||
print: Callable[..., None] | None = print,
|
||||
backlog: int = 128,
|
||||
access_log_class: Type[AbstractAccessLogger] = AccessLogger,
|
||||
access_log_class: type[AbstractAccessLogger] = AccessLogger,
|
||||
access_log_format: str = AccessLogger.LOG_FORMAT,
|
||||
access_log: Optional[logging.Logger] = access_logger,
|
||||
access_log: logging.Logger | None = access_logger,
|
||||
handle_signals: bool = True,
|
||||
reuse_address: Optional[bool] = None,
|
||||
reuse_port: Optional[bool] = None,
|
||||
reuse_address: bool | None = None,
|
||||
reuse_port: bool | None = None,
|
||||
handler_cancellation: bool = False,
|
||||
loop: Optional[asyncio.AbstractEventLoop] = None,
|
||||
loop: asyncio.AbstractEventLoop | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Run an app locally"""
|
||||
|
|
@ -512,16 +504,25 @@ def run_app(
|
|||
pass
|
||||
finally:
|
||||
try:
|
||||
main_task.cancel()
|
||||
with suppress(asyncio.CancelledError):
|
||||
loop.run_until_complete(main_task)
|
||||
# Skip when ``main_task`` is already done (e.g. raised during startup).
|
||||
# Re-running ``loop.run_until_complete`` on a finished task calls
|
||||
# ``Future.result`` again, which does
|
||||
# ``raise self._exception.with_traceback(self._exception_tb)`` and
|
||||
# resets ``exc.__traceback__`` to the originally saved tb — by then
|
||||
# shallow — clobbering the deep traceback the caller would otherwise
|
||||
# see (frames from ``cleanup_ctx`` / ``on_startup`` and the user code
|
||||
# that actually raised).
|
||||
if not main_task.done():
|
||||
main_task.cancel()
|
||||
with suppress(asyncio.CancelledError):
|
||||
loop.run_until_complete(main_task)
|
||||
finally:
|
||||
_cancel_tasks(asyncio.all_tasks(loop), loop)
|
||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||
loop.close()
|
||||
|
||||
|
||||
def main(argv: List[str]) -> None:
|
||||
def main(argv: list[str]) -> None:
|
||||
arg_parser = ArgumentParser(
|
||||
description="aiohttp.web Application server", prog="aiohttp.web"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue