From ec6a06bb33a69ef2d78e073efd2b137cf9e9f111 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:28:31 -0400 Subject: [PATCH] Expose `priority` for devices as well --- zigpy/device.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zigpy/device.py b/zigpy/device.py index 68ab80fcb..75a0ef6f0 100644 --- a/zigpy/device.py +++ b/zigpy/device.py @@ -101,7 +101,7 @@ def __init__(self, application: ControllerApplication, ieee: t.EUI64, nwk: t.NWK self.status = Status.NEW @contextlib.asynccontextmanager - async def _limit_concurrency(self): + async def _limit_concurrency(self, *, priority: int = 0): """Async context manager to limit device request concurrency.""" start_time = time.monotonic() @@ -114,7 +114,7 @@ async def _limit_concurrency(self): self._concurrent_requests_semaphore.num_waiting, ) - async with self._concurrent_requests_semaphore: + async with self._concurrent_requests_semaphore(priority=priority): if was_locked: LOGGER.debug( "Previously delayed device request is now running, delayed by %0.2fs", @@ -365,7 +365,7 @@ async def request( priority=priority, ) - async with self._limit_concurrency(): + async with self._limit_concurrency(priority=priority): if not expect_reply: await send_request() return None