summaryrefslogtreecommitdiff
path: root/src/apscheduler/abc.py
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-09-02 19:35:40 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-09-06 01:39:07 +0300
commit19d75e196aea88032e68535352bbdd9f528a214f (patch)
tree18b9b6eb6c59c33c5f5adc725f52d1c2c167a2b5 /src/apscheduler/abc.py
parentdbe0f8bdd58cef5bd9060ed4c6f9eb5651ce09ad (diff)
downloadapscheduler-19d75e196aea88032e68535352bbdd9f528a214f.tar.gz
More refactoring work
* Added mysql and sqlite to the data store testing matrix * Made customizing the SQLAlchemy table metadata easier * Refactored more classes to use attrs instead of dataclasses * Added the get_next_schedule_run_time() method to stores * Made schedulers use get_next_schedule_run_time() to limit their waiting time
Diffstat (limited to 'src/apscheduler/abc.py')
-rw-r--r--src/apscheduler/abc.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/apscheduler/abc.py b/src/apscheduler/abc.py
index acea751..ec77de5 100644
--- a/src/apscheduler/abc.py
+++ b/src/apscheduler/abc.py
@@ -3,9 +3,7 @@ from __future__ import annotations
from abc import ABCMeta, abstractmethod
from base64 import b64decode, b64encode
from datetime import datetime
-from typing import (
- TYPE_CHECKING, Any, AsyncContextManager, Callable, ContextManager, Iterable, Iterator, List,
- Optional, Set, Type)
+from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, List, Optional, Set, Type
from uuid import UUID
from .policies import ConflictPolicy
@@ -123,7 +121,7 @@ class DataStore(EventSource):
"""
@abstractmethod
- def acquire_schedules(self, scheduler_id: str, limit: int) -> ContextManager[List[Schedule]]:
+ def acquire_schedules(self, scheduler_id: str, limit: int) -> List[Schedule]:
"""
Acquire unclaimed due schedules for processing.
@@ -136,6 +134,22 @@ class DataStore(EventSource):
"""
@abstractmethod
+ def release_schedules(self, scheduler_id: str, schedules: List[Schedule]) -> None:
+ """
+ Release the claims on the given schedules and update them on the store.
+
+ :param scheduler_id: unique identifier of the scheduler
+ :param schedules: the previously claimed schedules
+ """
+
+ @abstractmethod
+ def get_next_schedule_run_time(self) -> Optional[datetime]:
+ """
+ Return the earliest upcoming run time of all the schedules in the store, or ``None`` if
+ there are no active schedules.
+ """
+
+ @abstractmethod
def add_job(self, job: Job) -> None:
"""
Add a job to be executed by an eligible worker.
@@ -222,8 +236,7 @@ class AsyncDataStore(EventSource):
"""
@abstractmethod
- async def acquire_schedules(self, scheduler_id: str,
- limit: int) -> AsyncContextManager[List[Schedule]]:
+ async def acquire_schedules(self, scheduler_id: str, limit: int) -> List[Schedule]:
"""
Acquire unclaimed due schedules for processing.
@@ -236,6 +249,22 @@ class AsyncDataStore(EventSource):
"""
@abstractmethod
+ async def release_schedules(self, scheduler_id: str, schedules: List[Schedule]) -> None:
+ """
+ Release the claims on the given schedules and update them on the store.
+
+ :param scheduler_id: unique identifier of the scheduler
+ :param schedules: the previously claimed schedules
+ """
+
+ @abstractmethod
+ async def get_next_schedule_run_time(self) -> Optional[datetime]:
+ """
+ Return the earliest upcoming run time of all the schedules in the store, or ``None`` if
+ there are no active schedules.
+ """
+
+ @abstractmethod
async def add_job(self, job: Job) -> None:
"""
Add a job to be executed by an eligible worker.