@@ -17,30 +17,20 @@ class Dispatch(BaseDispatch):
1717 deleted : bool = False
1818 """Whether the dispatch is deleted."""
1919
20- running_state_change_synced : datetime | None = None
21- """The last time a message was sent about the running state change."""
22-
2320 def __init__ (
2421 self ,
2522 client_dispatch : BaseDispatch ,
2623 deleted : bool = False ,
27- running_state_change_synced : datetime | None = None ,
2824 ):
2925 """Initialize the dispatch.
3026
3127 Args:
3228 client_dispatch: The client dispatch.
3329 deleted: Whether the dispatch is deleted.
34- running_state_change_synced: Timestamp of the last running state change message.
3530 """
3631 super ().__init__ (** client_dispatch .__dict__ )
3732 # Work around frozen to set deleted
3833 object .__setattr__ (self , "deleted" , deleted )
39- object .__setattr__ (
40- self ,
41- "running_state_change_synced" ,
42- running_state_change_synced ,
43- )
4434
4535 def _set_deleted (self ) -> None :
4636 """Mark the dispatch as deleted."""
@@ -58,40 +48,24 @@ def started(self) -> bool:
5848
5949 return super ().started
6050
61- @property
62- def _running_status_notified (self ) -> bool :
63- """Check that the latest running state change notification was sent.
64-
65- Returns:
66- True if the latest running state change notification was sent, False otherwise.
67- """
68- return self .running_state_change_synced == self .update_time
69-
70- def _set_running_status_notified (self ) -> None :
71- """Mark the latest running state change notification as sent."""
72- object .__setattr__ (self , "running_state_change_synced" , self .update_time )
73-
74- @property
7551 # noqa is needed because of a bug in pydoclint that makes it think a `return` without a return
7652 # value needs documenting
77- def missed_runs (self ) -> Iterator [datetime ]: # noqa: DOC405
53+ def missed_runs (self , since : datetime ) -> Iterator [datetime ]: # noqa: DOC405
7854 """Yield all missed runs of a dispatch.
7955
8056 Yields all missed runs of a dispatch.
8157
82- If a running state change notification was not sent in time
83- due to connection issues, this method will yield all missed runs
84- since the last sent notification.
58+ Args:
59+ since: The time to start checking for missed runs.
8560
8661 Returns:
8762 A generator that yields all missed runs of a dispatch.
88- """
89- if self .update_time == self .running_state_change_synced :
90- return
9163
92- from_time = self .update_time
64+ Yields:
65+ datetime: The missed run.
66+ """
9367 now = datetime .now (tz = timezone .utc )
9468
95- while (next_run := self .next_run_after (from_time )) and next_run < now :
69+ while (next_run := self .next_run_after (since )) and next_run < now :
9670 yield next_run
97- from_time = next_run
71+ since = next_run
0 commit comments