Skip to content

Serving

A handle for managing an async server instance. This class provides a clean interface for managing the lifecycle of a server without requiring manual management of the underlying task and server objects.

Lifecycle management for async servers returned by AnyAgent.serve_async().

FieldTypeDescription
taskasyncio.TaskThe server task
serverUvicornServerThe uvicorn server instance

Gracefully shutdown the server with a timeout.

async def shutdown(
self,
timeout_seconds: float = 10.0,
) -> None

Check if the server is still running.

def is_running(
self,
) -> bool
  • port - int: The actual server port (useful when port=0 for OS-assigned ports).