ReusePolicy
Configure a task environment for container reuse across multiple task invocations.
Attributes
| Attribute | Type | Description |
|---|---|---|
| replicas | Union[int, Tuple[int, int]] = 2 | Number of container replicas to maintain, specified as a fixed integer or a (min, max) tuple for auto-scaling. |
| idle_ttl | Union[int, timedelta] = 30 | Environment-level idle timeout that shuts down all replicas when the entire environment has been idle for this duration. |
| concurrency | int = 1 | Maximum concurrent tasks per replica, where values greater than 1 are only supported for async tasks. |
| scaledown_ttl | Union[int, timedelta] = 30 | Per-replica scale-down delay representing the minimum time to wait before removing an individual idle replica. |
Constructor
Signature
def ReusePolicy(
replicas: Union[int, Tuple[int, int]] = 2,
idle_ttl: Union[int, timedelta] = 30,
concurrency: int = 1,
scaledown_ttl: Union[int, timedelta] = 30
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| replicas | Union[int, Tuple[int, int]] = 2 | Number of container replicas to maintain. Can be a fixed integer or a tuple defining a (min, max) auto-scaling range. |
| idle_ttl | Union[int, timedelta] = 30 | Environment-level idle timeout in seconds or timedelta. Shuts down all replicas after the environment has been idle for this duration. |
| concurrency | int = 1 | Maximum concurrent tasks per replica. Values greater than 1 are only supported for async tasks. |
| scaledown_ttl | Union[int, timedelta] = 30 | Per-replica scale-down delay in seconds or timedelta. Minimum time to wait before removing an individual idle replica. |
Methods
min_replicas()
@classmethod
def min_replicas() - > int
Returns the minimum number of replicas.
Returns
| Type | Description |
|---|---|
int | The lower bound of the container replica count allowed for the environment. |
get_scaledown_ttl()
@classmethod
def get_scaledown_ttl() - > timedelta | None
Returns the scaledown TTL as a timedelta. If scaledown_ttl is not set, returns None.
Returns
| Type | Description |
|---|---|
| `timedelta | None` |
max_replicas()
@classmethod
def max_replicas() - > int
Returns the maximum number of replicas.
Returns
| Type | Description |
|---|---|
int | The upper bound of the container replica count allowed for the environment. |