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:
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user