INNER CODE UNIT · Python

forward_to_client

agentscope-ai/agentscope-runtime · src/agentscope_runtime/sandbox/manager/server/app.py:340

            async def forward_to_client():
                try:
                    async for message in target_ws:
                        await websocket.send_text(message)
                except websockets.exceptions.ConnectionClosed:
                    logger.debug(
                        f"WebSocket disconnected from service for sandbox"
                        f" {sandbox_id}",
                    )
                    await websocket.close()

            # Run both tasks concurrently
            await asyncio.gather(forward_to_service(), forward_to_client())

    except Exception as e:
        logger.error(f"Error in sandbox {sandbox_id}: {e}")
        await websocket.close()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…