Service node ends its call when the loop cancels every task; test order and timing leaks

_serve_once treated a cancelled call future as finished, so an event loop
cancelling all tasks at once (shutdown) never sent the worker a cancel and the
call's thread kept asyncio.run waiting for SILENCE_S. The cameras audio test
now removes its voice flow and device, the unpaired-frame test waits for its
first frame before the unpair, and test_connector no longer inherits the
controller an app test bound to demand.

Claude-Session: https://claude.ai/code/session_01SSi5AvZ7pFmySK8zy3NPMh
This commit is contained in:
2026-10-27 21:23:40 +01:00
parent 04d4c4792a
commit ab87cd1c07
4 changed files with 84 additions and 18 deletions
+4 -1
View File
@@ -190,7 +190,10 @@ class ServiceNode(Node):
# The worker went away or went silent, or the url was refused.
return healthy, f"{type(exc).__name__}: {exc}"
finally:
if not call.done():
# A cancelled future is done while its thread still waits for the
# worker, which is how an event loop cancelling every task at once
# (a shutdown) reaches here: only an answer means it has ended.
if not call.done() or call.cancelled():
# The flow stopped, or this side failed. Ending the call kills
# the server's process group on the worker, and its answer says
# that is done, so the next start finds the port free.