diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-12 16:11:13 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2021-09-13 01:07:44 +0300 |
commit | 9568bf2f1297c87ec1b93306b79de925fb2da08e (patch) | |
tree | 2969e7951f8883c41f1359ebbc98bcf85a3fdad6 /src/apscheduler/abc.py | |
parent | 0a6b0f683edee8bf22d85dc655ad61a8285fd312 (diff) | |
download | apscheduler-9568bf2f1297c87ec1b93306b79de925fb2da08e.tar.gz |
Implemented one-shot event subscriptions
Such subscriptions are delivered the first matching event and then unsubscribed automatically.
Diffstat (limited to 'src/apscheduler/abc.py')
-rw-r--r-- | src/apscheduler/abc.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/apscheduler/abc.py b/src/apscheduler/abc.py index 3d85eed..58d74cd 100644 --- a/src/apscheduler/abc.py +++ b/src/apscheduler/abc.py @@ -92,13 +92,16 @@ class EventSource(metaclass=ABCMeta): @abstractmethod def subscribe( self, callback: Callable[[Event], Any], - event_types: Optional[Iterable[type[Event]]] = None + event_types: Optional[Iterable[type[Event]]] = None, + *, + one_shot: bool = False ) -> Subscription: """ Subscribe to events from this event source. :param callback: callable to be called with the event object when an event is published :param event_types: an iterable of concrete Event classes to subscribe to + :param one_shot: if ``True``, automatically unsubscribe after the first matching event """ |