betty.job.scheduler package

Submodules

Module contents

Job scheduling.

exception betty.job.scheduler.Cancelled

Bases: Closed

Raised when a scheduler has cancelled.

exception betty.job.scheduler.Closed

Bases: Exception

Raised when a scheduler is closed.

final exception betty.job.scheduler.Completed

Bases: Closed

Raised when a scheduler has completed.

final exception betty.job.scheduler.CyclicDependencyError

Bases: Cancelled

Raised when a scheduler has cancelled due to a cyclic dependency.

__init__(job_ids: Sequence[str], /)
final exception betty.job.scheduler.DuplicateJobError

Bases: Cancelled

Raised when a scheduler cannot add the same job (ID) more than once.

__init__(job_id: str, /)
exception betty.job.scheduler.Released

Bases: Exception

Raised when a scheduler has been released.

class betty.job.scheduler.Scheduler

Bases: ABC

A job scheduler.

__init__(context: Context | None = None, /)
abstractmethod async add(*jobs: Job) None

Add a new job.

abstractmethod async cancel(reason: BaseException | None = None, /) None

Close the scheduler and cancel any pending jobs.

abstractmethod async complete() None

Close the scheduler and wait for any pending jobs to complete.

property context: Context

The context for all jobs in this scheduler.

abstractmethod async get() ScheduledJobBatch

Get a batch of jobs to execute.

abstractmethod async release() None

Release the scheduler.

Once called, jobs are released by betty.job.scheduler.Scheduler.get(), and new jobs with dependents can no longer be added.

final exception betty.job.scheduler.UnknownJobError

Bases: Cancelled

Raised when a scheduler has cancelled due to an unknown job.

__init__(job_id: str, /)