mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-02-26 03:21:46 +01:00
Reverse future done checks so we know they are actually reachable (#708)
This commit is contained in:
parent
3711d54ffa
commit
d592f1e7ab
@ -220,8 +220,7 @@ class APIConnection:
|
|||||||
if self._debug_enabled:
|
if self._debug_enabled:
|
||||||
_LOGGER.debug("Cleaning up connection to %s", self.log_name)
|
_LOGGER.debug("Cleaning up connection to %s", self.log_name)
|
||||||
for fut in self._read_exception_futures:
|
for fut in self._read_exception_futures:
|
||||||
if fut.done():
|
if not fut.done():
|
||||||
continue
|
|
||||||
err = self._fatal_exception or APIConnectionError("Connection closed")
|
err = self._fatal_exception or APIConnectionError("Connection closed")
|
||||||
new_exc = err
|
new_exc = err
|
||||||
if not isinstance(err, APIConnectionError):
|
if not isinstance(err, APIConnectionError):
|
||||||
@ -676,8 +675,7 @@ class APIConnection:
|
|||||||
|
|
||||||
def _handle_timeout(self, fut: asyncio.Future[None]) -> None:
|
def _handle_timeout(self, fut: asyncio.Future[None]) -> None:
|
||||||
"""Handle a timeout."""
|
"""Handle a timeout."""
|
||||||
if fut.done():
|
if not fut.done():
|
||||||
return
|
|
||||||
fut.set_exception(asyncio_TimeoutError)
|
fut.set_exception(asyncio_TimeoutError)
|
||||||
|
|
||||||
def _handle_complex_message(
|
def _handle_complex_message(
|
||||||
@ -689,8 +687,7 @@ class APIConnection:
|
|||||||
resp: message.Message,
|
resp: message.Message,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Handle a message that is part of a response."""
|
"""Handle a message that is part of a response."""
|
||||||
if fut.done():
|
if not fut.done():
|
||||||
return
|
|
||||||
if do_append is None or do_append(resp):
|
if do_append is None or do_append(resp):
|
||||||
responses.append(resp)
|
responses.append(resp)
|
||||||
if do_stop is None or do_stop(resp):
|
if do_stop is None or do_stop(resp):
|
||||||
|
Loading…
Reference in New Issue
Block a user