qlauncher.workflow.local_scheduler#
Summary#
Classes:
Run jobs locally using a per-job child process. |
|
Public-facing wrapper around _InnerMPTask. |
Functions:
Get timeout to wait on an event, useful when awaiting multiple tasks and total timeout must be max_timeout. |
Reference#
- qlauncher.workflow.local_scheduler.get_timeout(max_timeout: int | float | None, start: int | float) float | None[source]#
Get timeout to wait on an event, useful when awaiting multiple tasks and total timeout must be max_timeout.
- Parameters:
max_timeout (int | float | None) – Total allowed timeout, None = infinite wait.
start (int | float) – Await start timestamp (time.time())
- Returns:
Remaining timeout or None if max_timeout was None
- Return type:
int | float | None
- class qlauncher.workflow.local_scheduler.MPTask(task: Callable, callbacks: list[Callable] | None = None)[source]#
Bases:
objectPublic-facing wrapper around _InnerMPTask.
This wrapper exists so that if the task object is garbage-collected, we best-effort cancel the underlying execution to avoid leaking subprocesses.
- Parameters:
task (Callable) – Zero-argument callable to execute.
callbacks (list[Callable] | None) – Optional list of callables invoked with the task outcome.
- _inner_task#
The underlying _InnerMPTask instance.
- class qlauncher.workflow.local_scheduler.LocalJobManager(poll_interval_s: float = 0.05)[source]#
Bases:
BaseJobManagerRun jobs locally using a per-job child process.
This manager implements the BaseJobManager interface and is primarily intended for local execution and testing (supports waiting for any job, cancellation, and cleanup).
- submit(function: Callable, **kwargs) str[source]#
Submit a function job to the scheduler.
- Parameters:
function (Callable) – Function to be executed.
**kwargs – Manager-specific additional arguments (currently unused by LocalJobManager).
- Returns:
Job ID as a string.
- Return type:
str
- wait_for_a_job(job_id: str | None = None, timeout: float | None = None) str | None[source]#
Wait for a job to finish.
- Parameters:
job_id (str | None) – If provided, wait for this specific job. If None, wait for any unfinished job.
timeout (float | None) – Maximum time to wait in seconds. If None, wait indefinitely.
- Returns:
The finished job ID.
- Raises:
KeyError – If job_id is provided but unknown.
ValueError – If waiting for any job but no jobs exist.
TimeoutError – If timeout expires before a job finishes.
- Return type:
str | None
- read_results(job_id: str) Result[source]#
Read results for a finished job.
- Parameters:
job_id (str) – Job ID.
- Returns:
The job result.
- Raises:
KeyError – If job_id is unknown.
BaseException – Re-raises an exception produced by the job.
- Return type: