Skip to content

Commit

Permalink
enhance logging to use the tuple in _pending
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Dec 30, 2023
1 parent 555c323 commit cde5bb7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,20 +711,21 @@ def _handle_frame_sent(
cnt_name = f"unknown_msg_type_{msg}"

try:
request = self._pending[(destination, message_tag)]
pending_tag = (destination, message_tag)
request = self._pending[pending_tag]
request.result.set_result((status, f"message send {msg}"))
self.state.counters[COUNTERS_CTRL][cnt_name].increment()
except KeyError:
self.state.counters[COUNTERS_CTRL][f"{cnt_name}_unexpected"].increment()
LOGGER.debug("Unexpected message send notification tag: %s", message_tag)
LOGGER.debug("Unexpected message send notification tag: %s", pending_tag)
except asyncio.InvalidStateError as exc:
self.state.counters[COUNTERS_CTRL][f"{cnt_name}_duplicate"].increment()
LOGGER.debug(
(
"Invalid state on future for message tag %s "
"- probably duplicate response: %s"
),
message_tag,
pending_tag,
exc,
)

Expand Down Expand Up @@ -846,7 +847,8 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:

async with self._limit_concurrency():
message_tag = self.get_sequence()
with self._pending.new((packet.dst.address, message_tag)) as req:
pending_tag = (packet.dst.address, message_tag)
with self._pending.new(pending_tag) as req:
for attempt, retry_delay in enumerate(RETRY_DELAYS):
async with self._req_lock:
if packet.dst.addr_mode == zigpy.types.AddrMode.NWK:
Expand Down Expand Up @@ -901,7 +903,7 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
if attempt < len(RETRY_DELAYS):
LOGGER.debug(
"Request %s failed to enqueue, retrying in %ss: %s",
message_tag,
pending_tag,
retry_delay,
status,
)
Expand Down

0 comments on commit cde5bb7

Please sign in to comment.