File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
homeassistant/components/minecraft_server Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 55import logging
66from typing import Any
77
8+ import dns .asyncresolver
89import dns .rdata
910import dns .rdataclass
1011import dns .rdatatype
2223_LOGGER = logging .getLogger (__name__ )
2324
2425
25- def load_dnspython_rdata_classes () -> None :
26- """Load dnspython rdata classes used by mcstatus."""
26+ def prevent_dnspython_blocking_operations () -> None :
27+ """Prevent dnspython blocking operations by pre-loading required data."""
28+
29+ # Blocking import: https://github.com/rthalley/dnspython/issues/1083
2730 for rdtype in dns .rdatatype .RdataType :
2831 if not dns .rdatatype .is_metatype (rdtype ) or rdtype == dns .rdatatype .OPT :
2932 dns .rdata .get_rdata_class (dns .rdataclass .IN , rdtype ) # type: ignore[no-untyped-call]
3033
34+ # Blocking open: https://github.com/rthalley/dnspython/issues/1200
35+ dns .asyncresolver .get_default_resolver ()
36+
3137
3238async def async_setup_entry (
3339 hass : HomeAssistant , entry : MinecraftServerConfigEntry
3440) -> bool :
3541 """Set up Minecraft Server from a config entry."""
36-
37- # Workaround to avoid blocking imports from dnspython (https://github.com/rthalley/dnspython/issues/1083)
38- await hass .async_add_executor_job (load_dnspython_rdata_classes )
42+ await hass .async_add_executor_job (prevent_dnspython_blocking_operations )
3943
4044 # Create coordinator instance and store it.
4145 coordinator = MinecraftServerCoordinator (hass , entry )
You can’t perform that action at this time.
0 commit comments