Skip to content

Commit

Permalink
Fix blocking event loop calls (#156)
Browse files Browse the repository at this point in the history
* Run port discovery in thread (does anything use this?)

* Do not iterate over serial ports when probing
  • Loading branch information
puddly authored Jul 13, 2024
1 parent 0e3e5ae commit 1166711
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions zigpy_zigate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,5 @@ async def probe(cls, device_config: Dict[str, Any]) -> bool:

async def _probe(self) -> None:
"""Open port and try sending a command"""
try:
device = next(
serial.tools.list_ports.grep(
self._config[zigpy_zigate.config.CONF_DEVICE_PATH]
)
)
if device.description == "ZiGate":
return
except StopIteration:
pass
await self.connect()
await self.set_raw_mode()
2 changes: 1 addition & 1 deletion zigpy_zigate/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def connect(device_config: Dict[str, Any], api, loop=None):

port = device_config[CONF_DEVICE_PATH]
if port == "auto":
port = c.discover_port()
port = await loop.run_in_executor(None, c.discover_port)

if c.is_pizigate(port):
LOGGER.debug("PiZiGate detected")
Expand Down

0 comments on commit 1166711

Please sign in to comment.