mirror of
https://github.com/esphome/esphome.git
synced 2026-05-10 05:37:55 +08:00
[resolver] Make RESOLVE_TIMEOUT configurable via environment variable (#15951)
Co-authored-by: Daniel Lowe <dan@auth.dxj.app> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
+16
-1
@@ -2,13 +2,28 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from aioesphomeapi.core import ResolveAPIError, ResolveTimeoutAPIError
|
||||
import aioesphomeapi.host_resolver as hr
|
||||
|
||||
from esphome.async_thread import AsyncThreadRunner
|
||||
from esphome.core import EsphomeError
|
||||
|
||||
RESOLVE_TIMEOUT = 10.0 # seconds
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_DEFAULT_RESOLVE_TIMEOUT = 20.0
|
||||
_env_timeout = os.environ.get("ESPHOME_RESOLVE_TIMEOUT", _DEFAULT_RESOLVE_TIMEOUT)
|
||||
try:
|
||||
RESOLVE_TIMEOUT = float(_env_timeout)
|
||||
except ValueError:
|
||||
_LOGGER.warning(
|
||||
"ESPHOME_RESOLVE_TIMEOUT=%r is not a valid number; using default %.1fs",
|
||||
_env_timeout,
|
||||
_DEFAULT_RESOLVE_TIMEOUT,
|
||||
)
|
||||
RESOLVE_TIMEOUT = _DEFAULT_RESOLVE_TIMEOUT
|
||||
|
||||
|
||||
class AsyncResolver:
|
||||
|
||||
Reference in New Issue
Block a user