Repository navigation
Conversation
- test_tunnel_tunnel_arg, test_TCPInterface_writeBytes_reconnects and test_Tunnel_on_non_linux_system left reader threads spinning on MagicMocks, growing memory until the 3.14/3.15 CI runners were killed - Add an autouse conftest guard that fails any test leaving a 'stream reader' thread alive
- Drop dead sendall side-effect reset: noProto close() never writes - Track Thread objects, not idents, which the OS can reuse - Also guard BLEReceive, the BLE reader thread
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes the intermittent
build (3.14)/build (3.15.2)failures on master and on PRs: the runner either "lost communication with the server" or got a shutdown signal andmake: *** [Makefile:55: ci-test] Killed, often after every test had already passed.Cause
Three unit tests start a
StreamInterfacereader thread over a mocked transport and never close the interface:test_main.py::test_tunnel_tunnel_arg(SerialInterface, mockedserial.Serial)test_tcp_interface.py::test_TCPInterface_writeBytes_reconnects(TCPInterface, mockedsocket.socket)test_tunnel.py::test_Tunnel_on_non_linux_system(same)The reader loop never sleeps here:
read(1)/recv(1)returns a MagicMock whoselen()is 0, so it immediately reads again. MagicMock records every call, so memory grows for the rest of the session, and the threads compete for the GIL. At the end, pytest's unraisable-exception cleanup runsgc.collect()five times over that heap while the threads keep allocating. On 3.14+ this outlasts the runner's memory. Older versions usually finish first.Locally on Python 3.14,
pytest --cov=meshtastic --cov-report=xmlon master passed every test in 259 s, then hung ingc_collect_harderwith 1-3 GB RSS; a thread dump showed the threestream readerthreads inmock._increment_mock_call. With those three tests deselected: 18 s, exit 0, peak RSS 312 MB.Fix
try/finally).conftest.pythat fails any test leaving a newstream readerorBLEReceivethread alive, so the next leak shows up as a named test failure instead of a dead runner.Testing
pytest --cov=meshtastic --cov-report=xmlon Python 3.14: 570 passed, 2 skipped in 18.9 s, and the process exits (this env lacks a few optional extras, hence fewer tests than CI).test_tunnel.pyreverted, the new fixture failstest_Tunnel_on_non_linux_systemwith the leak message.Summary by CodeRabbit