diff --git a/goodwe/protocol.py b/goodwe/protocol.py index 347dcf7..3f49185 100644 --- a/goodwe/protocol.py +++ b/goodwe/protocol.py @@ -114,6 +114,8 @@ def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: else: logger.debug("Received invalid response: %s", data.hex()) asyncio.get_running_loop().call_soon(self._retry_mechanism) + except asyncio.InvalidStateError: + logger.debug("Response already handled: %s", data.hex()) except RequestRejectedException as ex: logger.debug("Received exception response: %s", data.hex()) self.response_future.set_exception(ex) @@ -226,6 +228,8 @@ def data_received(self, data: bytes) -> None: logger.debug("Received invalid response: %s", data.hex()) self.response_future.set_exception(RequestRejectedException()) self._close_transport() + except asyncio.InvalidStateError: + logger.debug("Response already handled: %s", data.hex()) except RequestRejectedException as ex: logger.debug("Received exception response: %s", data.hex()) self.response_future.set_exception(ex)