Skip to content

Commit 5d3c904

Browse files
authored
Ensure auto concurrency detection works with new zigpy defaults (#201)
1 parent e3c38aa commit 5d3c904

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

tests/application/test_startup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,18 @@ async def test_reset_network_info(device, make_application):
293293

294294
with pytest.raises(NetworkNotFormed):
295295
await app.start_network()
296+
297+
298+
@pytest.mark.parametrize(
299+
"device, concurrency",
300+
[
301+
(FormedLaunchpadCC26X2R1, 16),
302+
(FormedZStack1CC2531, 2),
303+
],
304+
)
305+
async def test_concurrency_auto_config(device, concurrency, make_application):
306+
app, znp_server = await make_application(server_cls=device)
307+
await app.connect()
308+
await app.start_network()
309+
310+
assert app._concurrent_requests_semaphore.max_value == concurrency

zigpy_znp/zigbee/application.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import zigpy.profiles
1717
import zigpy.zdo.types as zdo_t
1818
import zigpy.application
19+
import zigpy.config.defaults
1920
from zigpy.exceptions import DeliveryError
2021

2122
import zigpy_znp.const as const
@@ -228,7 +229,10 @@ async def start_network(self, *, read_only=False):
228229
)
229230

230231
# Now that we know what device we are, set the max concurrent requests
231-
if self._config[conf.CONF_MAX_CONCURRENT_REQUESTS] is None:
232+
if self._config[conf.CONF_MAX_CONCURRENT_REQUESTS] in (
233+
None,
234+
zigpy.config.defaults.CONF_MAX_CONCURRENT_REQUESTS_DEFAULT,
235+
):
232236
max_concurrent_requests = 16 if self._znp.nvram.align_structs else 2
233237
else:
234238
max_concurrent_requests = self._config[conf.CONF_MAX_CONCURRENT_REQUESTS]

0 commit comments

Comments
 (0)