Skip to content

Commit 012067a

Browse files
Copilotpuddly
andauthored
Reduce logging noise from security.py and update concurrency settings (#265)
* Initial plan * Change LOGGER.warning to LOGGER.debug in security.py Co-authored-by: puddly <[email protected]> * Remove PRE_COMMIT_CACHE_PATH and PYTHON_VERSION_DEFAULT from CI config Co-authored-by: puddly <[email protected]> * Replace serial_asyncio with serial_asyncio_fast in unit tests Co-authored-by: puddly <[email protected]> * Update concurrency from 2 to 4 and use max_concurrency instead of max_value Co-authored-by: puddly <[email protected]> * Fix locked() call to pass priority parameter Co-authored-by: puddly <[email protected]> * Add test coverage for debug logging in security.py Co-authored-by: puddly <[email protected]> * Revert "Add test coverage for debug logging in security.py" Co-authored-by: puddly <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: puddly <[email protected]>
1 parent fd9f7eb commit 012067a

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ jobs:
1010
with:
1111
CODE_FOLDER: zigpy_znp
1212
CACHE_VERSION: 2
13-
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit
14-
PYTHON_VERSION_DEFAULT: 3.9.15
1513
MINIMUM_COVERAGE_PERCENTAGE: 95
1614
secrets:
1715
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

tests/application/test_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ async def callback(req):
294294
nonlocal in_flight_requests
295295
nonlocal did_lock
296296

297-
if app._concurrent_requests_semaphore.locked():
297+
if app._concurrent_requests_semaphore.locked(priority=0):
298298
did_lock = True
299299

300300
in_flight_requests += 1

tests/application/test_startup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ async def test_reset_network_info(device, make_application):
304304
"device, concurrency",
305305
[
306306
(FormedLaunchpadCC26X2R1, 16),
307-
(FormedZStack1CC2531, 2),
307+
(FormedZStack1CC2531, 4),
308308
],
309309
)
310310
async def test_concurrency_auto_config(device, concurrency, make_application):
311311
app, znp_server = make_application(server_cls=device)
312312
await app.connect()
313313
await app.start_network()
314314

315-
assert app._concurrent_requests_semaphore.max_value == concurrency
315+
assert app._concurrent_requests_semaphore.max_concurrency == concurrency

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def passthrough_serial_conn(loop, protocol_factory, url, *args, **kwargs):
154154
return fut
155155

156156
mocker.patch(
157-
"serial_asyncio.create_serial_connection", new=passthrough_serial_conn
157+
"serial_asyncio_fast.create_serial_connection", new=passthrough_serial_conn
158158
)
159159

160160
# So we don't have to import it every time

tests/test_uart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
import pytest
4-
from serial_asyncio import SerialTransport
4+
from serial_asyncio_fast import SerialTransport
55

66
import zigpy_znp.types as t
77
import zigpy_znp.config as conf
@@ -47,7 +47,7 @@ def create_serial_conn(loop, protocol_factory, url, *args, **kwargs):
4747

4848
return fut
4949

50-
mocker.patch("serial_asyncio.create_serial_connection", new=create_serial_conn)
50+
mocker.patch("serial_asyncio_fast.create_serial_connection", new=create_serial_conn)
5151

5252
return device, serial_interface
5353

zigpy_znp/zigbee/application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ async def start_network(self, *, read_only=False):
187187
None,
188188
zigpy.config.defaults.CONF_MAX_CONCURRENT_REQUESTS_DEFAULT,
189189
):
190-
max_concurrent_requests = 16 if self._znp.nvram.align_structs else 2
190+
max_concurrent_requests = 16 if self._znp.nvram.align_structs else 4
191191
else:
192192
max_concurrent_requests = self._config[conf.CONF_MAX_CONCURRENT_REQUESTS]
193193

194194
# Update the max value of the concurrent request semaphore at runtime
195-
self._concurrent_requests_semaphore.max_value = max_concurrent_requests
195+
self._concurrent_requests_semaphore.max_concurrency = max_concurrent_requests
196196

197197
if self.state.network_info.network_key.key == const.Z2M_NETWORK_KEY:
198198
LOGGER.warning(

zigpy_znp/znp/security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ async def read_devices(
296296

297297
async for key in read_hashed_link_keys(znp, tclk_seed):
298298
if key.partner_ieee not in devices:
299-
LOGGER.warning(
299+
LOGGER.debug(
300300
"Skipping hashed link key %s (tx: %s, rx: %s) for unknown device %s",
301301
":".join(f"{b:02x}" for b in key.key),
302302
key.tx_counter,
@@ -309,7 +309,7 @@ async def read_devices(
309309

310310
async for key in read_unhashed_link_keys(znp, addr_mgr):
311311
if key.partner_ieee not in devices:
312-
LOGGER.warning(
312+
LOGGER.debug(
313313
"Skipping unhashed link key %s (tx: %s, rx: %s) for unknown device %s",
314314
":".join(f"{b:02x}" for b in key.key),
315315
key.tx_counter,

0 commit comments

Comments
 (0)