Better exception

This commit is contained in:
Adam Hopkins 2022-02-17 09:43:52 +02:00
parent 96a746e468
commit 6e3e5f1662
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB
2 changed files with 44 additions and 3 deletions

View File

@ -185,7 +185,9 @@ class RunnerMixin(metaclass=SanicMeta):
) -> None:
if version == 3 and self.state.server_info:
raise RuntimeError(
"Serving multiple HTTP/3 instances is not supported."
"Serving HTTP/3 instances as a secondary server is "
"not supported. There can only be a single HTTP/3 worker "
"and it must be prepared first."
)
if dev:

View File

@ -95,8 +95,47 @@ def serve(
app.asgi = False
if version is HTTP.VERSION_3:
return serve_http_3(host, port, app, loop, ssl)
return _serve_http_3(host, port, app, loop, ssl)
return _serve_http_1(
host,
port,
app,
ssl,
sock,
unix,
reuse_port,
loop,
protocol,
backlog,
register_sys_signals,
run_multiple,
run_async,
connections,
signal,
state,
asyncio_server_kwargs,
)
def _serve_http_1(
host,
port,
app,
ssl,
sock,
unix,
reuse_port,
loop,
protocol,
backlog,
register_sys_signals,
run_multiple,
run_async,
connections,
signal,
state,
asyncio_server_kwargs,
):
connections = connections if connections is not None else set()
protocol_kwargs = _build_protocol_kwargs(protocol, app.config)
server = partial(
@ -201,7 +240,7 @@ def serve(
remove_unix_socket(unix)
def serve_http_3(
def _serve_http_3(
host,
port,
app,