You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.9 KiB
Python
139 lines
3.9 KiB
Python
"""
|
|
This type stub file was generated by pyright.
|
|
"""
|
|
|
|
from abc import ABCMeta, abstractmethod
|
|
|
|
class JobLookupError(KeyError):
|
|
"""Raised when the job store cannot find a job for update or removal."""
|
|
def __init__(self, job_id) -> None:
|
|
...
|
|
|
|
|
|
|
|
class ConflictingIdError(KeyError):
|
|
"""Raised when the uniqueness of job IDs is being violated."""
|
|
def __init__(self, job_id) -> None:
|
|
...
|
|
|
|
|
|
|
|
class TransientJobError(ValueError):
|
|
"""
|
|
Raised when an attempt to add transient (with no func_ref) job to a persistent job store is
|
|
detected.
|
|
"""
|
|
def __init__(self, job_id) -> None:
|
|
...
|
|
|
|
|
|
|
|
class BaseJobStore(metaclass=ABCMeta):
|
|
"""Abstract base class that defines the interface that every job store must implement."""
|
|
_scheduler = ...
|
|
_alias = ...
|
|
_logger = ...
|
|
def start(self, scheduler, alias): # -> None:
|
|
"""
|
|
Called by the scheduler when the scheduler is being started or when the job store is being
|
|
added to an already running scheduler.
|
|
|
|
:param apscheduler.schedulers.base.BaseScheduler scheduler: the scheduler that is starting
|
|
this job store
|
|
:param str|unicode alias: alias of this job store as it was assigned to the scheduler
|
|
"""
|
|
...
|
|
|
|
def shutdown(self): # -> None:
|
|
"""Frees any resources still bound to this job store."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def lookup_job(self, job_id): # -> None:
|
|
"""
|
|
Returns a specific job, or ``None`` if it isn't found..
|
|
|
|
The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
|
|
the returned job to point to the scheduler and itself, respectively.
|
|
|
|
:param str|unicode job_id: identifier of the job
|
|
:rtype: Job
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def get_due_jobs(self, now): # -> None:
|
|
"""
|
|
Returns the list of jobs that have ``next_run_time`` earlier or equal to ``now``.
|
|
The returned jobs must be sorted by next run time (ascending).
|
|
|
|
:param datetime.datetime now: the current (timezone aware) datetime
|
|
:rtype: list[Job]
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def get_next_run_time(self): # -> None:
|
|
"""
|
|
Returns the earliest run time of all the jobs stored in this job store, or ``None`` if
|
|
there are no active jobs.
|
|
|
|
:rtype: datetime.datetime
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def get_all_jobs(self): # -> None:
|
|
"""
|
|
Returns a list of all jobs in this job store.
|
|
The returned jobs should be sorted by next run time (ascending).
|
|
Paused jobs (next_run_time == None) should be sorted last.
|
|
|
|
The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of
|
|
the returned jobs to point to the scheduler and itself, respectively.
|
|
|
|
:rtype: list[Job]
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def add_job(self, job): # -> None:
|
|
"""
|
|
Adds the given job to this store.
|
|
|
|
:param Job job: the job to add
|
|
:raises ConflictingIdError: if there is another job in this store with the same ID
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def update_job(self, job): # -> None:
|
|
"""
|
|
Replaces the job in the store with the given newer version.
|
|
|
|
:param Job job: the job to update
|
|
:raises JobLookupError: if the job does not exist
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def remove_job(self, job_id): # -> None:
|
|
"""
|
|
Removes the given job from this store.
|
|
|
|
:param str|unicode job_id: identifier of the job
|
|
:raises JobLookupError: if the job does not exist
|
|
"""
|
|
...
|
|
|
|
@abstractmethod
|
|
def remove_all_jobs(self): # -> None:
|
|
"""Removes all jobs from this store."""
|
|
...
|
|
|
|
def __repr__(self): # -> str:
|
|
...
|
|
|
|
|
|
|