Serving
any_agent.serving.ServerHandle
dataclass
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.
Source code in src/any_agent/serving/server_handle.py
port
property
Get the port the server is running on.
If the server port was specified as 0, the port will be the one assigned by the OS. This helper method is useful to get the actual port that the server is running on.
Returns:
Type | Description |
---|---|
int
|
The port number the server is running on. |
is_running()
Check if the server is still running.
Returns:
Type | Description |
---|---|
bool
|
True if the server task is still running, False otherwise. |
shutdown(timeout_seconds=10.0)
async
Gracefully shutdown the server with a timeout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout_seconds
|
float
|
Maximum time to wait for graceful shutdown before forcing cancellation. |
10.0
|