Skip to main content

ReusePolicy

Configure a task environment for container reuse across multiple task invocations.

Attributes

AttributeTypeDescription
replicasUnion[int, Tuple[int, int]] = 2Number of container replicas to maintain, specified as a fixed integer or a (min, max) tuple for auto-scaling.
idle_ttlUnion[int, timedelta] = 30Environment-level idle timeout that shuts down all replicas when the entire environment has been idle for this duration.
concurrencyint = 1Maximum concurrent tasks per replica, where values greater than 1 are only supported for async tasks.
scaledown_ttlUnion[int, timedelta] = 30Per-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

NameTypeDescription
replicasUnion[int, Tuple[int, int]] = 2Number of container replicas to maintain. Can be a fixed integer or a tuple defining a (min, max) auto-scaling range.
idle_ttlUnion[int, timedelta] = 30Environment-level idle timeout in seconds or timedelta. Shuts down all replicas after the environment has been idle for this duration.
concurrencyint = 1Maximum concurrent tasks per replica. Values greater than 1 are only supported for async tasks.
scaledown_ttlUnion[int, timedelta] = 30Per-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

TypeDescription
intThe 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

TypeDescription
`timedeltaNone`

max_replicas()

@classmethod
def max_replicas() - > int

Returns the maximum number of replicas.

Returns

TypeDescription
intThe upper bound of the container replica count allowed for the environment.