diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-05 23:17:20 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-06 01:39:07 +0300 |
commit | 2a685fe105b6c715c16912109dfc0f982e0acd5c (patch) | |
tree | 4dfd3473e5f631ea4dfabf1ea70b774c374f4313 | |
parent | 6fed43f29bfa7929fcaf5e549ce34819ba7e3702 (diff) | |
download | apscheduler-2a685fe105b6c715c16912109dfc0f982e0acd5c.tar.gz |
Moved the policy enums to the apscheduler.enums module
-rw-r--r-- | src/apscheduler/abc.py | 2 | ||||
-rw-r--r-- | src/apscheduler/datastores/async_/sqlalchemy.py | 2 | ||||
-rw-r--r-- | src/apscheduler/datastores/async_/sync_adapter.py | 2 | ||||
-rw-r--r-- | src/apscheduler/datastores/sync/memory.py | 2 | ||||
-rw-r--r-- | src/apscheduler/datastores/sync/mongodb.py | 2 | ||||
-rw-r--r-- | src/apscheduler/datastores/sync/sqlalchemy.py | 2 | ||||
-rw-r--r-- | src/apscheduler/enums.py | 18 | ||||
-rw-r--r-- | src/apscheduler/policies.py | 19 | ||||
-rw-r--r-- | src/apscheduler/schedulers/async_.py | 3 | ||||
-rw-r--r-- | src/apscheduler/schedulers/sync.py | 3 | ||||
-rw-r--r-- | src/apscheduler/structures.py | 3 | ||||
-rw-r--r-- | tests/test_datastores.py | 3 |
12 files changed, 28 insertions, 33 deletions
diff --git a/src/apscheduler/abc.py b/src/apscheduler/abc.py index 19c5a02..90346b4 100644 --- a/src/apscheduler/abc.py +++ b/src/apscheduler/abc.py @@ -6,7 +6,7 @@ from datetime import datetime from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, List, Optional, Set, Type from uuid import UUID -from .policies import ConflictPolicy +from .enums import ConflictPolicy from .structures import Job, JobResult, Schedule, Task if TYPE_CHECKING: diff --git a/src/apscheduler/datastores/async_/sqlalchemy.py b/src/apscheduler/datastores/async_/sqlalchemy.py index 00e9efc..8495831 100644 --- a/src/apscheduler/datastores/async_/sqlalchemy.py +++ b/src/apscheduler/datastores/async_/sqlalchemy.py @@ -23,13 +23,13 @@ from sqlalchemy.sql.elements import BindParameter, literal from ... import events as events_module from ...abc import AsyncDataStore, Job, Schedule, Serializer +from ...enums import ConflictPolicy from ...events import ( AsyncEventHub, DataStoreEvent, Event, JobAdded, JobDeserializationFailed, ScheduleAdded, ScheduleDeserializationFailed, ScheduleRemoved, ScheduleUpdated, SubscriptionToken, TaskAdded, TaskRemoved) from ...exceptions import ConflictingIdError, SerializationError, TaskLookupError from ...marshalling import callable_to_ref -from ...policies import ConflictPolicy from ...serializers.pickle import PickleSerializer from ...structures import JobResult, Task from ...util import reentrant diff --git a/src/apscheduler/datastores/async_/sync_adapter.py b/src/apscheduler/datastores/async_/sync_adapter.py index 4f81196..aef79c7 100644 --- a/src/apscheduler/datastores/async_/sync_adapter.py +++ b/src/apscheduler/datastores/async_/sync_adapter.py @@ -11,8 +11,8 @@ from anyio.from_thread import BlockingPortal from ... import events from ...abc import AsyncDataStore, DataStore +from ...enums import ConflictPolicy from ...events import Event, SubscriptionToken -from ...policies import ConflictPolicy from ...structures import Job, JobResult, Schedule, Task from ...util import reentrant diff --git a/src/apscheduler/datastores/sync/memory.py b/src/apscheduler/datastores/sync/memory.py index 4239dc7..2e93433 100644 --- a/src/apscheduler/datastores/sync/memory.py +++ b/src/apscheduler/datastores/sync/memory.py @@ -11,11 +11,11 @@ import attr from ... import events from ...abc import DataStore, Job, Schedule +from ...enums import ConflictPolicy from ...events import ( EventHub, JobAdded, ScheduleAdded, ScheduleRemoved, ScheduleUpdated, SubscriptionToken, TaskAdded, TaskRemoved) from ...exceptions import ConflictingIdError, TaskLookupError -from ...policies import ConflictPolicy from ...structures import JobResult, Task from ...util import reentrant diff --git a/src/apscheduler/datastores/sync/mongodb.py b/src/apscheduler/datastores/sync/mongodb.py index fcf7d4d..3d963ac 100644 --- a/src/apscheduler/datastores/sync/mongodb.py +++ b/src/apscheduler/datastores/sync/mongodb.py @@ -15,12 +15,12 @@ from pymongo.errors import DuplicateKeyError from ... import events from ...abc import DataStore, Job, Schedule, Serializer +from ...enums import ConflictPolicy from ...events import ( DataStoreEvent, EventHub, JobAdded, ScheduleAdded, ScheduleRemoved, ScheduleUpdated, SubscriptionToken, TaskAdded, TaskRemoved) from ...exceptions import ( ConflictingIdError, DeserializationError, SerializationError, TaskLookupError) -from ...policies import ConflictPolicy from ...serializers.pickle import PickleSerializer from ...structures import JobResult, Task from ...util import reentrant diff --git a/src/apscheduler/datastores/sync/sqlalchemy.py b/src/apscheduler/datastores/sync/sqlalchemy.py index 3b1d2bf..07118ba 100644 --- a/src/apscheduler/datastores/sync/sqlalchemy.py +++ b/src/apscheduler/datastores/sync/sqlalchemy.py @@ -15,13 +15,13 @@ from sqlalchemy.sql.ddl import DropTable from sqlalchemy.sql.elements import BindParameter, literal from ...abc import DataStore, Job, Schedule, Serializer +from ...enums import ConflictPolicy from ...events import ( Event, EventHub, JobAdded, JobDeserializationFailed, ScheduleAdded, ScheduleDeserializationFailed, ScheduleRemoved, ScheduleUpdated, SubscriptionToken, TaskAdded, TaskRemoved) from ...exceptions import ConflictingIdError, SerializationError, TaskLookupError from ...marshalling import callable_to_ref -from ...policies import ConflictPolicy from ...serializers.pickle import PickleSerializer from ...structures import JobResult, Task from ...util import reentrant diff --git a/src/apscheduler/enums.py b/src/apscheduler/enums.py index 941de3a..f9300de 100644 --- a/src/apscheduler/enums.py +++ b/src/apscheduler/enums.py @@ -14,3 +14,21 @@ class JobOutcome(Enum): missed_start_deadline = auto() cancelled = auto() expired = auto() + + +class ConflictPolicy(Enum): + #: 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): + #: 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() diff --git a/src/apscheduler/policies.py b/src/apscheduler/policies.py deleted file mode 100644 index 91fbd31..0000000 --- a/src/apscheduler/policies.py +++ /dev/null @@ -1,19 +0,0 @@ -from enum import Enum, auto - - -class ConflictPolicy(Enum): - #: 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): - #: 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() diff --git a/src/apscheduler/schedulers/async_.py b/src/apscheduler/schedulers/async_.py index 708d2ec..010b3ce 100644 --- a/src/apscheduler/schedulers/async_.py +++ b/src/apscheduler/schedulers/async_.py @@ -16,12 +16,11 @@ from anyio.abc import TaskGroup from ..abc import AsyncDataStore, DataStore, EventSource, Job, Schedule, Trigger from ..datastores.async_.sync_adapter import AsyncDataStoreAdapter from ..datastores.sync.memory import MemoryDataStore -from ..enums import RunState +from ..enums import CoalescePolicy, ConflictPolicy, RunState from ..events import ( AsyncEventHub, ScheduleAdded, SchedulerStarted, SchedulerStopped, ScheduleUpdated, SubscriptionToken) from ..marshalling import callable_to_ref -from ..policies import CoalescePolicy, ConflictPolicy from ..structures import Task from ..workers.async_ import AsyncWorker diff --git a/src/apscheduler/schedulers/sync.py b/src/apscheduler/schedulers/sync.py index 3d86b25..b80210d 100644 --- a/src/apscheduler/schedulers/sync.py +++ b/src/apscheduler/schedulers/sync.py @@ -12,12 +12,11 @@ from uuid import uuid4 from ..abc import DataStore, EventSource, Trigger from ..datastores.sync.memory import MemoryDataStore -from ..enums import RunState +from ..enums import CoalescePolicy, ConflictPolicy, RunState from ..events import ( Event, EventHub, ScheduleAdded, SchedulerStarted, SchedulerStopped, ScheduleUpdated, SubscriptionToken) from ..marshalling import callable_to_ref -from ..policies import CoalescePolicy, ConflictPolicy from ..structures import Job, Schedule, Task from ..workers.sync import Worker diff --git a/src/apscheduler/structures.py b/src/apscheduler/structures.py index 2f97ca6..eeab5ac 100644 --- a/src/apscheduler/structures.py +++ b/src/apscheduler/structures.py @@ -7,9 +7,8 @@ from uuid import UUID, uuid4 import attr from . import abc -from .enums import JobOutcome +from .enums import CoalescePolicy, JobOutcome from .marshalling import callable_from_ref, callable_to_ref -from .policies import CoalescePolicy @attr.define(kw_only=True) diff --git a/tests/test_datastores.py b/tests/test_datastores.py index 2751c83..b4342d5 100644 --- a/tests/test_datastores.py +++ b/tests/test_datastores.py @@ -9,9 +9,8 @@ import pytest from freezegun.api import FrozenDateTimeFactory from apscheduler.abc import AsyncDataStore, Job, Schedule -from apscheduler.enums import JobOutcome +from apscheduler.enums import CoalescePolicy, ConflictPolicy, JobOutcome from apscheduler.events import Event, ScheduleAdded, ScheduleRemoved, ScheduleUpdated, TaskAdded -from apscheduler.policies import CoalescePolicy, ConflictPolicy from apscheduler.structures import JobResult, Task from apscheduler.triggers.date import DateTrigger |