Skip to content

Commit fdd4cc4

Browse files
committed
Derive from BaseSite
1 parent a97f464 commit fdd4cc4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

matter_server/server/helpers/custom_web_runner.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""MultiHost capable aiohttp Site."""
22
from __future__ import annotations
33

4+
import asyncio
45
from ssl import SSLContext
56

67
from aiohttp import web
78
from yarl import URL
89

910

10-
class MultiHostTCPSite(web.TCPSite):
11+
class MultiHostTCPSite(web.BaseSite):
1112
"""MultiHost capable aiohttp Site.
1213
1314
Vanilla TCPSite accepts only str as host. However, the underlying asyncio's
@@ -16,6 +17,8 @@ class MultiHostTCPSite(web.TCPSite):
1617
explicitly), we would like to pass an array of strings.
1718
"""
1819

20+
__slots__ = ("_host", "_port", "_reuse_address", "_reuse_port", "_hosturl")
21+
1922
def __init__(
2023
self,
2124
runner: web.BaseRunner,
@@ -44,3 +47,19 @@ def name(self) -> str:
4447
scheme = "https" if self._ssl_context else "http"
4548
host = self._host[0] if isinstance(self._host, list) else "0.0.0.0"
4649
return str(URL.build(scheme=scheme, host=host, port=self._port))
50+
51+
async def start(self) -> None:
52+
"""Start server."""
53+
await super().start()
54+
loop = asyncio.get_running_loop()
55+
server = self._runner.server
56+
assert server is not None
57+
self._server = await loop.create_server(
58+
server,
59+
self._host,
60+
self._port,
61+
ssl=self._ssl_context,
62+
backlog=self._backlog,
63+
reuse_address=self._reuse_address,
64+
reuse_port=self._reuse_port,
65+
)

0 commit comments

Comments
 (0)