Skip to content

Commit

Permalink
Use single SDK worker Thread (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
agners authored Feb 28, 2024
1 parent 9344e8b commit 712a726
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import asyncio
from collections import deque
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from functools import partial
import logging
Expand Down Expand Up @@ -106,6 +107,7 @@ def __init__(
self._node_lock: dict[int, asyncio.Lock] = {}
self._aiobrowser: AsyncServiceBrowser | None = None
self._aiozc: AsyncZeroconf | None = None
self._sdk_executor = ThreadPoolExecutor(max_workers=1)

async def initialize(self) -> None:
"""Async initialize of controller."""
Expand Down Expand Up @@ -1027,7 +1029,7 @@ async def _call_sdk(self, func: Callable[..., _T], *args: Any, **kwargs: Any) ->
return cast(
_T,
await self.server.loop.run_in_executor(
None,
self._sdk_executor,
partial(func, *args, **kwargs),
),
)
Expand Down

0 comments on commit 712a726

Please sign in to comment.