Skip to content

Commit

Permalink
Remove (pointless) resolve lock (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored Jan 3, 2024
1 parent fa56a2f commit 9ad2f39
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(
self.wifi_credentials_set: bool = False
self.thread_credentials_set: bool = False
self.compressed_fabric_id: int | None = None
self._resolve_lock: asyncio.Lock = asyncio.Lock()
self._node_lock: dict[int, asyncio.Lock] = {}

async def initialize(self) -> None:
Expand Down Expand Up @@ -938,22 +937,19 @@ async def _resolve_node(
if self.chip_controller is None:
raise RuntimeError("Device Controller not initialized.")
try:
# the sdk crashes when multiple resolves happen at the same time
# guard simultane resolves with a lock.
async with self._resolve_lock:
LOGGER.log(
log_level,
"Attempting to resolve node %s... (attempt %s of %s)",
node_id,
attempt,
retries,
)
return await self._call_sdk(
self.chip_controller.GetConnectedDeviceSync,
nodeid=node_id,
allowPASE=False,
timeoutMs=None,
)
LOGGER.log(
log_level,
"Attempting to resolve node %s... (attempt %s of %s)",
node_id,
attempt,
retries,
)
return await self._call_sdk(
self.chip_controller.GetConnectedDeviceSync,
nodeid=node_id,
allowPASE=False,
timeoutMs=None,
)
except (ChipStackError, TimeoutError) as err:
if attempt >= retries:
# when we're out of retries, raise NodeNotResolving
Expand Down

0 comments on commit 9ad2f39

Please sign in to comment.