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. |
| idle_ttl | Union[int, timedelta] = 30 | Environment-level idle timeout — shuts down all replicas when the entire environment has been idle for this duration. |
| concurrency | int = 1 | Maximum concurrent tasks per replica. |
| scaledown_ttl | Union[int, timedelta] = 30 | Per-replica scale-down delay — 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
) -> None
Parameters
| Name | Type | Description |
|---|---|---|
| replicas | Union[int, Tuple[int, int]] = 2 | Number of container replicas to maintain as a fixed integer or a (min, max) tuple for auto-scaling. |
| idle_ttl | Union[int, timedelta] = 30 | Environment-level idle timeout in seconds or timedelta after which all replicas are shut down. |
| concurrency | int = 1 | Maximum concurrent tasks per replica. |
| scaledown_ttl | Union[int, timedelta] = 30 | Per-replica scale-down delay in seconds or timedelta before removing an individual idle replica. |
Methods
min_replicas()
@property
def min_replicas(self) -> int: ...
Returns the minimum number of replicas.
Returns
| Type | Description |
|---|---|
int | The minimum number of container replicas configured to run. |
get_scaledown_ttl()
def get_scaledown_ttl(self) -> timedelta | None: ...
Returns the scaledown TTL as a timedelta. If scaledown_ttl is not set, returns None.
Returns
| Type | Description |
|---|---|
| `timedelta | None` |
max_replicas()
@property
def max_replicas(self) -> int: ...
Returns the maximum number of replicas.
Returns
| Type | Description |
|---|---|
int | The maximum number of container replicas allowed to run. |