()
| 1475 | ) |
| 1476 | |
| 1477 | async def worker(): |
| 1478 | try: |
| 1479 | async with Aclosing( |
| 1480 | runner.run_async( |
| 1481 | user_id=req.user_id, |
| 1482 | session_id=req.session_id, |
| 1483 | new_message=req.new_message, |
| 1484 | state_delta=req.state_delta, |
| 1485 | invocation_id=req.invocation_id, |
| 1486 | run_config=run_config, |
| 1487 | ) |
| 1488 | ) as agen: |
| 1489 | return [event async for event in agen] |
| 1490 | except SessionNotFoundError as e: |
| 1491 | raise HTTPException(status_code=404, detail=str(e)) from e |
| 1492 | |
| 1493 | worker_task = asyncio.create_task(worker()) |
| 1494 |