Skip to content

Commit 2b1b21f

Browse files
committed
Limit request concurrency
1 parent 8314dcd commit 2b1b21f

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

zigpy_xbee/zigbee/application.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -302,29 +302,30 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
302302
"Cannot send a packet to a device without a known IEEE address"
303303
)
304304

305-
send_req = self._api.tx_explicit(
306-
long_addr,
307-
short_addr,
308-
packet.src_ep or 0,
309-
packet.dst_ep or 0,
310-
packet.cluster_id,
311-
packet.profile_id,
312-
packet.radius,
313-
tx_opts,
314-
packet.data.serialize(),
315-
)
316-
317-
try:
318-
v = await asyncio.wait_for(send_req, timeout=TIMEOUT_TX_STATUS)
319-
except asyncio.TimeoutError:
320-
raise zigpy.exceptions.DeliveryError(
321-
"Timeout waiting for ACK", status=TXStatus.NETWORK_ACK_FAILURE
305+
async with self._limit_concurrency():
306+
send_req = self._api.tx_explicit(
307+
long_addr,
308+
short_addr,
309+
packet.src_ep or 0,
310+
packet.dst_ep or 0,
311+
packet.cluster_id,
312+
packet.profile_id,
313+
packet.radius,
314+
tx_opts,
315+
packet.data.serialize(),
322316
)
323317

324-
if v != TXStatus.SUCCESS:
325-
raise zigpy.exceptions.DeliveryError(
326-
f"Failed to deliver packet: {v!r}", status=v
327-
)
318+
try:
319+
v = await asyncio.wait_for(send_req, timeout=TIMEOUT_TX_STATUS)
320+
except asyncio.TimeoutError:
321+
raise zigpy.exceptions.DeliveryError(
322+
"Timeout waiting for ACK", status=TXStatus.NETWORK_ACK_FAILURE
323+
)
324+
325+
if v != TXStatus.SUCCESS:
326+
raise zigpy.exceptions.DeliveryError(
327+
f"Failed to deliver packet: {v!r}", status=v
328+
)
328329

329330
@zigpy.util.retryable_request()
330331
def remote_at_command(

0 commit comments

Comments
 (0)