Use symmetric spawn-then-run() pattern in multi-task examples

Switch every example to ``await runner.spawn(task)`` followed by
``await runner.run()`` (no task argument), and ``await runner.cancel()``
on client-disconnected instead of ``await task.cancel()``. This makes
the main pipeline task look the same as the worker / proxy tasks
spawned alongside it, and lets ``runner.cancel()`` drive a uniform
shutdown across every root task on the bus.
This commit is contained in:
Aleix Conchillo Flaqué
2026-05-15 08:46:46 -07:00
parent 5f1b91bb89
commit f22350ce2f
6 changed files with 31 additions and 25 deletions

View File

@@ -104,8 +104,10 @@ async def websocket_endpoint(websocket: WebSocket):
assistant = AcmeAssistant()
await runner.spawn(proxy)
await runner.spawn(assistant)
logger.info("Assistant server ready, waiting for activation")
await runner.run(assistant)
await runner.run()
logger.info("Assistant server session ended")