perago.worker_child_specs#

perago.worker_child_specs(*, base_env, module_target, process_count)[源代码]#

Build stable worker child specifications for a supervisor run.

The supervisor uses these specs for perago start -j. Each child receives a one-based slot and a deterministic PERAGO_WORKER_ID derived from the configured prefix or, when no prefix is configured, from module_target.

Parameters:
base_envdict of str to str

Base environment copied into every child. PERAGO_WORKER_ID_PREFIX is honored when present.

module_targetstr

Python import path of the single task module served by all child workers.

process_countint

Number of worker child specs to create. Must be at least one.

Returns:
list of WorkerChildSpec

Child launch specs ordered by ascending slot.

Raises:
RuntimeConfigError

If process_count is less than one or if the worker id prefix is invalid.

参数:
返回类型:

list[WorkerChildSpec]

参见

WorkerChildSpec

Value object returned for each child slot.

restart_backoff_seconds

Restart delay used after a child exits.

Examples

>>> [spec.worker_id for spec in worker_child_specs(
...     base_env={"PERAGO_WORKER_ID_PREFIX": "featuresBuild"},
...     module_target="app.workers.features_build",
...     process_count=2,
... )]
['featuresBuild0001', 'featuresBuild0002']