Skip to content

Commit 6eb9ff1

Browse files
committed
Speed up stopping the reconnect logic if we are at a safe place to cancel
If the connection has not established yet, we can cancel the connection process when the reconnect logic is stopped instead of waiting for the connection to fail. If we have already finished connecting and started the handshake, we wait for it to complete so we can try to disconnect cleanly
1 parent f4d297a commit 6eb9ff1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

aioesphomeapi/reconnect_logic.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ async def start(self) -> None:
317317
async def stop(self) -> None:
318318
"""Stop the connecting logic background task. Does not disconnect the client."""
319319
self._cancel_connect("Stopping")
320-
if self._connect_task and self._connection_state == ReconnectLogicState.CONNECTING:
320+
if (
321+
self._connect_task
322+
and self._connection_state == ReconnectLogicState.CONNECTING
323+
):
321324
# If we are still establishing a connection, we can safely
322325
# cancel the connect task here, otherwise we need to wait
323326
# for the connect task to finish so we can gracefully

0 commit comments

Comments
 (0)