Skip to content

Commit

Permalink
Make sure we do not resolve the future right away
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Dec 30, 2023
1 parent 5396997 commit 9c8889d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions zigpy_deconz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}")

Expand Down

0 comments on commit 9c8889d

Please sign in to comment.