Skip to content

Commit 29b735c

Browse files
committed
Fix Python 3.7 bug due to CancelledError being a subclass of Exception
Reference: https://bugs.python.org/issue32528
1 parent a6217ed commit 29b735c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

zigpy_znp/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def connect(self, *, test_port=True) -> None:
260260
self.version = await detect_zstack_version(self)
261261

262262
LOGGER.debug("Detected Z-Stack %s", self.version)
263-
except Exception:
263+
except (Exception, asyncio.CancelledError):
264264
LOGGER.debug("Connection to %s failed, cleaning up", self._port_path)
265265
self.close()
266266
raise

zigpy_znp/zigbee/application.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ async def _reconnect(self) -> None:
11141114
try:
11151115
await self._startup()
11161116
return
1117+
except asyncio.CancelledError:
1118+
raise
11171119
except Exception as e:
11181120
LOGGER.error("Failed to reconnect", exc_info=e)
11191121

0 commit comments

Comments
 (0)