From f748b18d26119385a4f7e1097db333d5a56d6148 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 3 Aug 2025 09:31:47 -0700 Subject: [PATCH 1/3] chore: Add timeout to queue request to diagnose --- tests/test_a01_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_a01_api.py b/tests/test_a01_api.py index cac85bd8..4a6ec99f 100644 --- a/tests/test_a01_api.py +++ b/tests/test_a01_api.py @@ -207,8 +207,8 @@ async def test_set_value( """Test sending an arbitrary MQTT message and parsing the response.""" # Clear existing messages received during setup assert received_requests.qsize() == 2 - assert received_requests.get(block=True) - assert received_requests.get(block=True) + assert received_requests.get(block=True, timeout=QUEUE_TIMEOUT) + assert received_requests.get(block=True, timeout=QUEUE_TIMEOUT) assert received_requests.empty() # Prepare the response message From 01a7d5f192b073c2c1ce7d9d70b061648bf1cf71 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 3 Aug 2025 16:15:19 -0700 Subject: [PATCH 2/3] chore: fix a01 client cleanup --- tests/test_a01_api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_a01_api.py b/tests/test_a01_api.py index 4a6ec99f..0ec4f982 100644 --- a/tests/test_a01_api.py +++ b/tests/test_a01_api.py @@ -37,6 +37,9 @@ from .conftest import QUEUE_TIMEOUT +RELEASE_TIMEOUT = 2 + + @pytest.fixture(name="a01_mqtt_client") async def a01_mqtt_client_fixture( mock_create_connection: None, mock_select: None @@ -59,9 +62,11 @@ async def a01_mqtt_client_fixture( try: yield client finally: - if not client.is_connected(): + # Cleanup is best effort to reduce number of active threads + if client.is_connected(): try: - await client.async_release() + async with asyncio.timeout(RELEASE_TIMEOUT): + await client.async_release() except Exception: pass From d09881701c5f6c21e72b384ab225ee430cf1592d Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 3 Aug 2025 16:16:54 -0700 Subject: [PATCH 3/3] chore: fix lint errors --- tests/test_a01_api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_a01_api.py b/tests/test_a01_api.py index 0ec4f982..796d1438 100644 --- a/tests/test_a01_api.py +++ b/tests/test_a01_api.py @@ -36,7 +36,6 @@ from . import mqtt_packet from .conftest import QUEUE_TIMEOUT - RELEASE_TIMEOUT = 2