|
| 1 | +from _typeshed import Incomplete, StrOrBytesPath, SupportsRead, SupportsWrite |
| 2 | +from abc import ABCMeta, abstractmethod |
| 3 | +from collections.abc import Callable, Iterable, Mapping |
| 4 | +from datetime import date, datetime, tzinfo |
| 5 | +from typing import Any, Final, TypeVar, overload |
| 6 | +from typing_extensions import deprecated |
| 7 | + |
| 8 | +from apscheduler.job import Job |
| 9 | +from apscheduler.jobstores.base import BaseJobStore |
| 10 | +from apscheduler.triggers.base import BaseTrigger |
| 11 | + |
| 12 | +_F = TypeVar("_F", bound=Callable[..., Any]) |
| 13 | + |
| 14 | +STATE_STOPPED: Final = 0 |
| 15 | +STATE_RUNNING: Final = 1 |
| 16 | +STATE_PAUSED: Final = 2 |
| 17 | + |
| 18 | +class BaseScheduler(metaclass=ABCMeta): |
| 19 | + # One of STATE_STOPPED, STATE_RUNNING and STATE_PAUSED. |
| 20 | + state: int |
| 21 | + # Set by configure, and by the constructor through it. |
| 22 | + timezone: tzinfo |
| 23 | + jobstore_retry_interval: float |
| 24 | + def __init__(self, gconfig: Mapping[str, Any] = {}, **options: Any) -> None: ... |
| 25 | + def configure(self, gconfig: Mapping[str, Any] = {}, prefix: str | None = "apscheduler.", **options: Any) -> None: ... |
| 26 | + def start(self, paused: bool = False) -> None: ... |
| 27 | + @abstractmethod |
| 28 | + def shutdown(self, wait: bool = True) -> None: ... |
| 29 | + def pause(self) -> None: ... |
| 30 | + def resume(self) -> None: ... |
| 31 | + @property |
| 32 | + def running(self) -> bool: ... |
| 33 | + # An executor is an apscheduler.executors.base.BaseExecutor or the name of an executor plugin. |
| 34 | + def add_executor(self, executor, alias: str = "default", **executor_opts: Any) -> None: ... |
| 35 | + def remove_executor(self, alias: str, shutdown: bool = True) -> None: ... |
| 36 | + # A job store, or the name of a job store plugin. |
| 37 | + def add_jobstore(self, jobstore: BaseJobStore | str, alias: str = "default", **jobstore_opts: Any) -> None: ... |
| 38 | + def remove_jobstore(self, alias: str, shutdown: bool = True) -> None: ... |
| 39 | + # The callback is called with an apscheduler.events.SchedulerEvent. |
| 40 | + def add_listener(self, callback: Callable[[Incomplete], object], mask: int = ...) -> None: ... |
| 41 | + def remove_listener(self, callback: Callable[[Incomplete], object]) -> None: ... |
| 42 | + def add_job( |
| 43 | + self, |
| 44 | + func: Callable[..., object] | str, |
| 45 | + trigger: BaseTrigger | str | None = None, |
| 46 | + args: Iterable[Any] | None = None, |
| 47 | + kwargs: Mapping[str, Any] | None = None, |
| 48 | + id: str | None = None, |
| 49 | + name: str | None = None, |
| 50 | + misfire_grace_time: int | None = ..., |
| 51 | + coalesce: bool = ..., |
| 52 | + max_instances: int = ..., |
| 53 | + next_run_time: datetime | date | str | None = ..., |
| 54 | + jobstore: str = "default", |
| 55 | + executor: str = "default", |
| 56 | + replace_existing: bool = False, |
| 57 | + **trigger_args: Any, |
| 58 | + ) -> Job: ... |
| 59 | + def scheduled_job( |
| 60 | + self, |
| 61 | + trigger: BaseTrigger | str | None, |
| 62 | + args: Iterable[Any] | None = None, |
| 63 | + kwargs: Mapping[str, Any] | None = None, |
| 64 | + id: str | None = None, |
| 65 | + name: str | None = None, |
| 66 | + misfire_grace_time: int | None = ..., |
| 67 | + coalesce: bool = ..., |
| 68 | + max_instances: int = ..., |
| 69 | + next_run_time: datetime | date | str | None = ..., |
| 70 | + jobstore: str = "default", |
| 71 | + executor: str = "default", |
| 72 | + **trigger_args: Any, |
| 73 | + ) -> Callable[[_F], _F]: ... |
| 74 | + def modify_job(self, job_id: str, jobstore: str | None = None, **changes: Any) -> Job: ... |
| 75 | + def reschedule_job( |
| 76 | + self, job_id: str, jobstore: str | None = None, trigger: BaseTrigger | str | None = None, **trigger_args: Any |
| 77 | + ) -> Job: ... |
| 78 | + def pause_job(self, job_id: str, jobstore: str | None = None) -> Job: ... |
| 79 | + # None when the job's trigger gives no next run time, the job then removed. |
| 80 | + def resume_job(self, job_id: str, jobstore: str | None = None) -> Job | None: ... |
| 81 | + |
| 82 | + @overload |
| 83 | + def get_jobs(self, jobstore: str | None = None, pending: None = None) -> list[Job]: ... |
| 84 | + @overload |
| 85 | + @deprecated( |
| 86 | + 'The "pending" option is deprecated -- get_jobs() always returns scheduled jobs if the scheduler has been ' |
| 87 | + "started and pending jobs otherwise" |
| 88 | + ) |
| 89 | + def get_jobs(self, jobstore: str | None, pending: bool) -> list[Job]: ... |
| 90 | + @overload |
| 91 | + @deprecated( |
| 92 | + 'The "pending" option is deprecated -- get_jobs() always returns scheduled jobs if the scheduler has been ' |
| 93 | + "started and pending jobs otherwise" |
| 94 | + ) |
| 95 | + def get_jobs(self, jobstore: str | None = None, *, pending: bool) -> list[Job]: ... |
| 96 | + |
| 97 | + def get_job(self, job_id: str, jobstore: str | None = None) -> Job | None: ... |
| 98 | + def remove_job(self, job_id: str, jobstore: str | None = None) -> None: ... |
| 99 | + def remove_all_jobs(self, jobstore: str | None = None) -> None: ... |
| 100 | + def print_jobs(self, jobstore: str | None = None, out: SupportsWrite[str] | None = None) -> None: ... |
| 101 | + def export_jobs(self, outfile: SupportsWrite[str] | StrOrBytesPath, jobstore: str | None = None) -> None: ... |
| 102 | + def import_jobs(self, infile: SupportsRead[str] | StrOrBytesPath, jobstore: str = "default") -> None: ... |
| 103 | + @abstractmethod |
| 104 | + def wakeup(self) -> None: ... |
0 commit comments