From c87479b738d9c1fd4ded1caefb215d428002be39 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 17 Oct 2024 18:50:51 -0400 Subject: [PATCH 1/3] Move more sync functions to executor --- zigpy_zigate/common.py | 2 ++ zigpy_zigate/uart.py | 4 ++-- zigpy_zigate/zigbee/application.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/zigpy_zigate/common.py b/zigpy_zigate/common.py index 2951176..b87c446 100644 --- a/zigpy_zigate/common.py +++ b/zigpy_zigate/common.py @@ -174,3 +174,5 @@ async def replacement(*args): async_set_pizigate_flashing_mode = async_run_in_executor(set_pizigate_flashing_mode) async_set_zigatedin_running_mode = async_run_in_executor(set_zigatedin_running_mode) async_set_zigatedin_flashing_mode = async_run_in_executor(set_zigatedin_flashing_mode) +async_is_pizigate = async_run_in_executor(is_pizigate) +async_is_zigate_din = async_run_in_executor(is_zigate_din) diff --git a/zigpy_zigate/uart.py b/zigpy_zigate/uart.py index 1401561..57b455a 100644 --- a/zigpy_zigate/uart.py +++ b/zigpy_zigate/uart.py @@ -142,13 +142,13 @@ async def connect(device_config: Dict[str, Any], api, loop=None): if port == "auto": port = await loop.run_in_executor(None, c.discover_port) - if c.is_pizigate(port): + if await c.async_is_pizigate(port): LOGGER.debug("PiZiGate detected") await c.async_set_pizigate_running_mode() # in case of pizigate:/dev/ttyAMA0 syntax if port.startswith("pizigate:"): port = port.replace("pizigate:", "", 1) - elif c.is_zigate_din(port): + elif await c.async_is_zigate_din(port): LOGGER.debug("ZiGate USB DIN detected") await c.async_set_zigatedin_running_mode() elif c.is_zigate_wifi(port): diff --git a/zigpy_zigate/zigbee/application.py b/zigpy_zigate/zigbee/application.py index 6dd49ac..9b7718c 100644 --- a/zigpy_zigate/zigbee/application.py +++ b/zigpy_zigate/zigbee/application.py @@ -83,9 +83,9 @@ async def load_network_info(self, *, load_devices: bool = False): if c.is_zigate_wifi(port): model = "ZiGate WiFi" - elif c.is_pizigate(port): + elif await c.async_is_pizigate(port): model = "PiZiGate" - elif c.is_zigate_din(port): + elif await c.async_is_zigate_din(port): model = "ZiGate USB-DIN" else: model = "ZiGate USB-TTL" From 94ab3b040213a1099849482f5e046e6cb46cd728 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 17 Oct 2024 18:52:54 -0400 Subject: [PATCH 2/3] Drop explicit default Python version from CI --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddebd6e..4b2ec6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,6 @@ jobs: with: CODE_FOLDER: zigpy_zigate CACHE_VERSION: 2 - PYTHON_VERSION_DEFAULT: 3.8.14 PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit MINIMUM_COVERAGE_PERCENTAGE: 46 secrets: From ce8dd7bb7bea7a87ce42508f4a67e23233c00a5e Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:10:31 -0400 Subject: [PATCH 3/3] Oops --- zigpy_zigate/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zigpy_zigate/common.py b/zigpy_zigate/common.py index b87c446..8322652 100644 --- a/zigpy_zigate/common.py +++ b/zigpy_zigate/common.py @@ -162,7 +162,7 @@ def async_run_in_executor(function): """Decorator to make a sync function async.""" async def replacement(*args): - return asyncio.get_running_loop().run_in_executor(None, function, *args) + return await asyncio.get_running_loop().run_in_executor(None, function, *args) replacement._sync_func = function