Skip to content

Commit 49def51

Browse files
committed
Limit request concurrency
1 parent 28d275b commit 49def51

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

zigpy_xbee/zigbee/application.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -302,30 +302,31 @@ 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._command(
306-
"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(),
316-
)
317-
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
305+
async with self._limit_concurrency():
306+
send_req = self._api._command(
307+
"tx_explicit",
308+
long_addr,
309+
short_addr,
310+
packet.src_ep or 0,
311+
packet.dst_ep or 0,
312+
packet.cluster_id,
313+
packet.profile_id,
314+
packet.radius,
315+
tx_opts,
316+
packet.data.serialize(),
323317
)
324318

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

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

0 commit comments

Comments
 (0)