Skip to content

Commit

Permalink
Handle late arriving response which was already handled/canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
mletenay committed May 12, 2024
1 parent 337a799 commit 35f6465
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions goodwe/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 35f6465

Please sign in to comment.