mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-02-22 02:42:19 +01:00
Fix race condition
This commit is contained in:
parent
d37602cfdd
commit
9bcb7f1cce
@ -600,10 +600,14 @@ class APIClient:
|
||||
raise APIConnectionError("Already connected!")
|
||||
|
||||
connected = False
|
||||
stopped = False
|
||||
|
||||
async def _on_stop():
|
||||
if self._connection is None:
|
||||
nonlocal stopped
|
||||
|
||||
if stopped:
|
||||
return
|
||||
stopped = True
|
||||
self._connection = None
|
||||
if connected and on_stop is not None:
|
||||
await on_stop()
|
||||
|
Loading…
Reference in New Issue
Block a user