From 9c8889d96205c8437366a01da3ab81385523b61a Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:04:13 -0500 Subject: [PATCH] Make sure we do not resolve the future right away --- zigpy_deconz/api.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/zigpy_deconz/api.py b/zigpy_deconz/api.py index 48e1130..f63e218 100644 --- a/zigpy_deconz/api.py +++ b/zigpy_deconz/api.py @@ -654,15 +654,6 @@ def data_received(self, data: bytes) -> None: self._mismatched_response_timers.pop(command.seq).cancel() if wrong_fut_cmd_id is not None: - exc = MismatchedResponseError( - command.command_id, - params, - ( - f"Response is mismatched! Sent {wrong_fut_cmd_id}," - f" received {command.command_id}" - ), - ) - LOGGER.debug( "Mismatched response, triggering error in %0.2fs", MISMATCHED_RESPONSE_TIMEOUT, @@ -671,8 +662,20 @@ def data_received(self, data: bytes) -> None: self._mismatched_response_timers[ command.seq ] = asyncio.get_event_loop().call_later( - MISMATCHED_RESPONSE_TIMEOUT, fut.set_exception, exc + MISMATCHED_RESPONSE_TIMEOUT, + fut.set_exception, + MismatchedResponseError( + command.command_id, + params, + ( + f"Response is mismatched! Sent {wrong_fut_cmd_id}," + f" received {command.command_id}" + ), + ), ) + + # Make sure we do not resolve the future + fut = None elif status != Status.SUCCESS: exc = CommandError(status, f"{command.command_id}, status: {status}")