s365b.jobs.tasks¶
Procrastinate tasks and the worker app.
There is no separate scheduler process: Procrastinate workers run periodic
tasks themselves, and a database lock makes sure each tick runs once even
with several workers. Every minute, scheduler_tick() queues the backup
jobs whose cron schedule is due.
Attributes¶
Functions¶
|
Return this worker's services, created on first use. |
|
Run a backup job (queued by the scheduler or the UI). |
|
Run a restore queued from Browse. |
|
Queue backup jobs whose schedule is due this minute. |
|
Apply a repository's retention policy (nightly, or from the UI). |
|
At the configured hour, queue retention for every repository. |
|
Email the events that are due (every minute). |
|
Return the Procrastinate app for this database (one per process). |
Module Contents¶
- s365b.jobs.tasks.services() s365b.core.services.Services[source]¶
Return this worker’s services, created on first use.
- Returns:
The services.
- async s365b.jobs.tasks.run_backup_job(job_id: int, requested_by: str = 'scheduler') int[source]¶
Run a backup job (queued by the scheduler or the UI).
- Parameters:
job_id – Backup job ID.
requested_by – Who started it.
- Returns:
The job run ID.
- async s365b.jobs.tasks.run_restore(run_id: int) int[source]¶
Run a restore queued from Browse.
- Parameters:
run_id – The queued job run.
- Returns:
The job run ID.
- async s365b.jobs.tasks.scheduler_tick(timestamp: int) list[int][source]¶
Queue backup jobs whose schedule is due this minute.
A queueing lock per job prevents a second run from being queued while one is still waiting.
- Parameters:
timestamp – The scheduled minute (Unix time), from Procrastinate.
- Returns:
IDs of jobs queued.
- async s365b.jobs.tasks.run_retention(repository_id: int, requested_by: str = 'scheduler', attempt: int = 1) int[source]¶
Apply a repository’s retention policy (nightly, or from the UI).
If a backup is writing to the repository, the run is recorded as skipped and retried 30 minutes later.
- Parameters:
repository_id – Repository row ID.
requested_by – Who started it.
attempt – Retry counter.
- Returns:
The job run ID.
- async s365b.jobs.tasks.retention_tick(timestamp: int) list[int][source]¶
At the configured hour, queue retention for every repository.
Also deletes audit log entries and alerts past their retention.
- Parameters:
timestamp – The scheduled hour (Unix time), from Procrastinate.
- Returns:
IDs of repositories queued.
- async s365b.jobs.tasks.deliver_notifications(timestamp: int) dict[str, int][source]¶
Email the events that are due (every minute).
- Parameters:
timestamp – The scheduled minute (Unix time), from Procrastinate.
- Returns:
Count of events per outcome.
- s365b.jobs.tasks.build_app(settings: s365b.core.config.Settings) procrastinate.App[source]¶
Return the Procrastinate app for this database (one per process).
add_tasks_fromrenames the blueprint’s tasks in place, so building a second app would turns365b:run_backup_jobintos365b:s365b:run_backup_job, a task no worker knows. The app is therefore built once and reused.- Parameters:
settings – Process settings.
- Returns:
The app (open it with
open_asyncbefore use).