From 29a8868ad79aedbd01eba78c596ea838e3b29cbe Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 1 Mar 2024 15:02:21 +0100 Subject: [PATCH] Detect deadlock on node subscription setup (#613) --- matter_server/server/device_controller.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index cfc8bd7b..9504faa0 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -14,6 +14,7 @@ import time from typing import TYPE_CHECKING, Any, Callable, Iterable, TypeVar, cast +import async_timeout from chip.ChipDeviceCtrl import DeviceProxyWrapper from chip.clusters import Attribute, Objects as Clusters from chip.clusters.Attribute import ValueDecodeFailure @@ -1111,7 +1112,14 @@ async def _setup_node(self, node_id: int) -> None: return # setup subscriptions for the node try: - await self._subscribe_node(node_id) + async with async_timeout.timeout(15 * 60): + await self._subscribe_node(node_id) + except TimeoutError: + LOGGER.warning( + "Setting up subscriptions for node %s did not " + "succeed after 15 minutes!", + node_id, + ) except (NodeNotResolving, ChipStackError) as err: LOGGER.warning( "Unable to subscribe to Node %s: %s",