Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move more sync functions to executor #159

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion zigpy_zigate/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
4 changes: 2 additions & 2 deletions zigpy_zigate/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions zigpy_zigate/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading