Skip to content

Commit 7b09393

Browse files
authored
Cleanup: Drop setup node timer (#881)
1 parent 6e7ffd7 commit 7b09393

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

matter_server/server/device_controller.py

-42
Original file line numberDiff line numberDiff line change
@@ -1293,55 +1293,14 @@ async def _setup_node_try_once(
12931293
) -> None:
12941294
"""Handle set-up of subscriptions and interview (if needed) for known/discovered node."""
12951295
node_data = self._nodes[node_id]
1296-
log_timers: dict[int, asyncio.TimerHandle] = {}
12971296
is_thread_node = (
12981297
node_data.attributes.get(ROUTING_ROLE_ATTRIBUTE_PATH) is not None
12991298
)
13001299

1301-
async def log_node_long_setup(time_start: float) -> None:
1302-
"""Temporary measure to track a locked-up SDK issue in some (special) circumstances."""
1303-
time_mins = int((time.time() - time_start) / 60)
1304-
# get productlabel or modelname from raw attributes
1305-
node_model = node_data.attributes.get(
1306-
"0/40/14", node_data.attributes.get("0/40/3", "")
1307-
)
1308-
node_name = f"Node {node_id} ({node_model})"
1309-
# get current IP the sdk is using to communicate with the device
1310-
if sdk_ip_info := await self._chip_device_controller.get_address_and_port(
1311-
node_id
1312-
):
1313-
ip_address = sdk_ip_info[0]
1314-
else:
1315-
ip_address = "unknown"
1316-
1317-
node_logger.error(
1318-
f"\n\nATTENTION: {node_name} did not complete setup in {time_mins} minutes.\n" # noqa: G004
1319-
"This is an indication of a (connectivity) issue with this device. \n"
1320-
f"IP-address in use for this device: {ip_address}\n"
1321-
"Try powercycling this device and/or relocate it closer to a Border Router or \n"
1322-
"WiFi Access Point. If this issue persists, please create an issue report on \n"
1323-
"the Matter channel of the Home Assistant Discord server or on Github:\n"
1324-
"https://github.com/home-assistant/core/issues/new?assignees=&labels="
1325-
"integration%3A%20matter&projects=&template=bug_report.yml\n",
1326-
)
1327-
# reschedule itself
1328-
log_timers[node_id] = self._loop.call_later(
1329-
15 * 60, lambda: asyncio.create_task(log_node_long_setup(time_start))
1330-
)
1331-
# release semaphore to give an additional free slot for setup
1332-
# otherwise no thread nodes will be setup if 5 are stuck in this state
1333-
if is_thread_node:
1334-
self._thread_node_setup_throttle.release()
1335-
13361300
# use semaphore for thread based devices to (somewhat)
13371301
# throttle the traffic that setup/initial subscription generates
13381302
if is_thread_node:
13391303
await self._thread_node_setup_throttle.acquire()
1340-
time_start = time.time()
1341-
# we want to track nodes that take too long so we log it when we detect that
1342-
log_timers[node_id] = self._loop.call_later(
1343-
15 * 60, lambda: asyncio.create_task(log_node_long_setup(time_start))
1344-
)
13451304

13461305
try:
13471306
node_logger.info("Setting-up node...")
@@ -1397,7 +1356,6 @@ async def log_node_long_setup(time_start: float) -> None:
13971356
self._polled_attributes[node_id] = polled_attributes
13981357
self._schedule_custom_attributes_poller()
13991358
finally:
1400-
log_timers[node_id].cancel()
14011359
if is_thread_node:
14021360
self._thread_node_setup_throttle.release()
14031361

0 commit comments

Comments
 (0)