mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 04:06:33 +00:00
Fallback to threaded resolver in case AsyncResolver fails (#5882)
In case the c-ares based AsyncResolver fails to initialize, let's fallback to the threaded resolver. This would have helped for aiodns 3.3.0 issue when clients were unable to allocate more inotify watches. This is fixed in aiodns 3.4.0, but we should still fallback to the threaded resolver as a precautionary measure.
This commit is contained in:
parent
154aeaee87
commit
da0ae75e8e
@ -13,6 +13,7 @@ from types import MappingProxyType
|
||||
from typing import TYPE_CHECKING, Any, Self, TypeVar
|
||||
|
||||
import aiohttp
|
||||
from pycares import AresError
|
||||
|
||||
from .config import CoreConfig
|
||||
from .const import (
|
||||
@ -121,13 +122,17 @@ class CoreSys:
|
||||
if self._websession:
|
||||
await self._websession.close()
|
||||
|
||||
resolver = aiohttp.AsyncResolver()
|
||||
try:
|
||||
resolver = aiohttp.AsyncResolver(loop=self.loop)
|
||||
# pylint: disable=protected-access
|
||||
_LOGGER.debug(
|
||||
"Initializing ClientSession with AsyncResolver. Using nameservers %s",
|
||||
resolver._resolver.nameservers,
|
||||
)
|
||||
except AresError as err:
|
||||
_LOGGER.exception("Unable to initialize async DNS resolver: %s", err)
|
||||
resolver = aiohttp.ThreadedResolver(loop=self.loop)
|
||||
|
||||
# pylint: disable=protected-access
|
||||
_LOGGER.debug(
|
||||
"Initializing ClientSession with AsyncResolver. Using nameservers %s",
|
||||
resolver._resolver.nameservers,
|
||||
)
|
||||
connector = aiohttp.TCPConnector(loop=self.loop, resolver=resolver)
|
||||
|
||||
session = aiohttp.ClientSession(
|
||||
|
Loading…
x
Reference in New Issue
Block a user