mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-22 16:48:04 +01:00
Fix race while disconnecting after connect timeout (#295)
This commit is contained in:
parent
770cd70f73
commit
cb6b1595b7
@ -484,10 +484,11 @@ class APIClient:
|
||||
await event.wait()
|
||||
except asyncio.TimeoutError as err:
|
||||
unsub()
|
||||
# Disconnect before raising the exception to ensure
|
||||
# the slot is recovered before the timeout is raised
|
||||
# to avoid race were we run out even though we have a slot.
|
||||
await self.bluetooth_device_disconnect(address)
|
||||
raise TimeoutAPIError("Timeout waiting for connect response") from err
|
||||
finally:
|
||||
if not event.is_set():
|
||||
await self.bluetooth_device_disconnect(address)
|
||||
|
||||
return unsub
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user