fix: manage WebRTC pipeline shutdown
This commit is contained in:
@@ -810,14 +810,22 @@ async def run_pipeline(
|
||||
)
|
||||
runner = WorkerRunner(handle_sigint=False)
|
||||
run_status = "completed"
|
||||
can_finalize_recorder = True
|
||||
try:
|
||||
await runner.add_workers(worker)
|
||||
await runner.run()
|
||||
except GeneratorExit:
|
||||
# A coroutine being synchronously closed cannot perform async cleanup.
|
||||
# The WebRTC route now prevents this by retaining every pipeline task;
|
||||
# keep this guard so a future unmanaged caller cannot corrupt asyncpg.
|
||||
run_status = "failed"
|
||||
can_finalize_recorder = False
|
||||
raise
|
||||
except Exception:
|
||||
run_status = "failed"
|
||||
raise
|
||||
finally:
|
||||
if recorder:
|
||||
if recorder and can_finalize_recorder:
|
||||
await recorder.finish(status=run_status)
|
||||
logger.info("管线已结束")
|
||||
|
||||
@@ -971,13 +979,18 @@ async def run_realtime_pipeline(
|
||||
)
|
||||
runner = WorkerRunner(handle_sigint=False)
|
||||
run_status = "completed"
|
||||
can_finalize_recorder = True
|
||||
try:
|
||||
await runner.add_workers(worker)
|
||||
await runner.run()
|
||||
except GeneratorExit:
|
||||
run_status = "failed"
|
||||
can_finalize_recorder = False
|
||||
raise
|
||||
except Exception:
|
||||
run_status = "failed"
|
||||
raise
|
||||
finally:
|
||||
if recorder:
|
||||
if recorder and can_finalize_recorder:
|
||||
await recorder.finish(status=run_status)
|
||||
logger.info("Realtime 管线已结束")
|
||||
|
||||
Reference in New Issue
Block a user