Skip to content

Ensure auto concurrency detection works with new zigpy defaults #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/application/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,18 @@ async def test_reset_network_info(device, make_application):

with pytest.raises(NetworkNotFormed):
await app.start_network()


@pytest.mark.parametrize(
"device, concurrency",
[
(FormedLaunchpadCC26X2R1, 16),
(FormedZStack1CC2531, 2),
],
)
async def test_concurrency_auto_config(device, concurrency, make_application):
app, znp_server = await make_application(server_cls=device)
await app.connect()
await app.start_network()

assert app._concurrent_requests_semaphore.max_value == concurrency
6 changes: 5 additions & 1 deletion zigpy_znp/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import zigpy.profiles
import zigpy.zdo.types as zdo_t
import zigpy.application
import zigpy.config.defaults
from zigpy.exceptions import DeliveryError

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

# Now that we know what device we are, set the max concurrent requests
if self._config[conf.CONF_MAX_CONCURRENT_REQUESTS] is None:
if self._config[conf.CONF_MAX_CONCURRENT_REQUESTS] in (
None,
zigpy.config.defaults.CONF_MAX_CONCURRENT_REQUESTS_DEFAULT,
):
max_concurrent_requests = 16 if self._znp.nvram.align_structs else 2
else:
max_concurrent_requests = self._config[conf.CONF_MAX_CONCURRENT_REQUESTS]
Expand Down