diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-08-16 00:47:44 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-08-16 01:17:45 +0300 |
commit | 6371198f4df8557751b968235c583191f243abe2 (patch) | |
tree | 892e2541dc7e130e96f9fe6be7671401988af470 | |
parent | 23bf672fd0f74a76a966c9fda2468a707ab250be (diff) | |
download | apscheduler-6371198f4df8557751b968235c583191f243abe2.tar.gz |
Improved the documentation of the enumerated types
The values did not show up in the documentation before this.
-rw-r--r-- | docs/api.rst | 14 | ||||
-rw-r--r-- | src/apscheduler/_enums.py | 53 |
2 files changed, 46 insertions, 21 deletions
diff --git a/docs/api.rst b/docs/api.rst index f6c1fd5..15461ee 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -92,9 +92,17 @@ Enumerated types Context variables ----------------- -.. autodata:: apscheduler.current_scheduler -.. autodata:: apscheduler.current_worker -.. autodata:: apscheduler.current_job +See the :mod:`contextvars` module for information on how to work with context variables. + +.. data:: apscheduler.current_scheduler + :annotation: the current scheduler + :type: ~contextvars.ContextVar[~typing.Union[Scheduler, AsyncScheduler]] +.. data:: apscheduler.current_worker + :annotation: the current scheduler + :type: ~contextvars.ContextVar[~typing.Union[Worker, AsyncWorker]] +.. data:: apscheduler.current_job + :annotation: information on the job being currently run + :type: ~contextvars.ContextVar[JobInfo] Exceptions ---------- diff --git a/src/apscheduler/_enums.py b/src/apscheduler/_enums.py index 139333a..d8e706d 100644 --- a/src/apscheduler/_enums.py +++ b/src/apscheduler/_enums.py @@ -4,29 +4,39 @@ from enum import Enum, auto class RunState(Enum): - """Used to track the running state of schedulers and workers.""" + """ + Used to track the running state of schedulers and workers. + + Values: + + * ``starting``: not running yet, but in the process of starting + * ``started``: running + * ``stopping``: still running but in the process of shutting down + * ``stopped``: not running + """ - #: not running yet, but in the process of starting starting = auto() - #: running started = auto() - #: still running but in the process of shutting down stopping = auto() - #: not running stopped = auto() class JobOutcome(Enum): - """Used to indicate how the execution of a job ended.""" + """ + Used to indicate how the execution of a job ended. + + Values: + + * ``success``: the job completed successfully + * ``error``: the job raised an exception + * ``missed_start_deadline``: the job's execution was delayed enough for it to miss + its deadline + * ``cancelled``: the job's execution was cancelled + """ - #: the job completed successfully success = auto() - #: the job raised an exception error = auto() - #: the job's execution was delayed enough for it to miss its designated run time by - #: too large a margin missed_start_deadline = auto() - #: the job's execution was cancelled cancelled = auto() @@ -34,24 +44,31 @@ class ConflictPolicy(Enum): """ Used to indicate what to do when trying to add a schedule whose ID conflicts with an existing schedule. + + Values: + + * ``replace``: replace the existing schedule with a new one + * ``do_nothing``: keep the existing schedule as-is and drop the new schedule + * ``exception``: raise an exception if a conflict is detected """ - #: replace the existing schedule with a new one replace = auto() - #: keep the existing schedule as-is and drop the new schedule do_nothing = auto() - #: raise an exception if a conflict is detected exception = auto() class CoalescePolicy(Enum): """ - Used to indicate how to + Used to indicate how to queue jobs for a schedule that has accumulated multiple + run times since the last scheduler iteration. + + Values: + + * ``earliest``: run once, with the earliest fire time + * ``latest``: run once, with the latest fire time + * ``all``: submit one job for every accumulated fire time """ - #: run once, with the earliest fire time earliest = auto() - #: run once, with the latest fire time latest = auto() - #: submit one job for every accumulated fire time all = auto() |