File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -119,11 +119,11 @@ def running(self, type_: str) -> RunningState:
119
119
120
120
now = datetime .now (tz = timezone .utc )
121
121
122
- # A dispatch without duration is always running once it started
123
- if self .duration is None :
124
- if self .start_time <= now :
125
- return RunningState .RUNNING
122
+ if now < self .start_time :
126
123
return RunningState .STOPPED
124
+ # A dispatch without duration is always running once it started
125
+ elif self .duration is None :
126
+ return RunningState .RUNNING
127
127
128
128
if until := self ._until (now ):
129
129
return RunningState .RUNNING if now < until else RunningState .STOPPED
Original file line number Diff line number Diff line change @@ -130,6 +130,8 @@ async def _execute_scheduled_event(self, dispatch: Dispatch) -> None:
130
130
else :
131
131
self ._schedule_start (dispatch )
132
132
133
+ self ._update_timer ()
134
+
133
135
async def _fetch (self ) -> None :
134
136
"""Fetch all relevant dispatches using list.
135
137
@@ -234,10 +236,14 @@ async def _update_dispatch_schedule_and_notify(
234
236
self ._schedule_start (dispatch )
235
237
236
238
# We modified the schedule, so we need to reset the timer
239
+ self ._update_timer ()
240
+
241
+ def _update_timer (self ) -> None :
242
+ """Update the timer to the next event."""
237
243
if self ._scheduled_events :
238
- _logger .debug ("Next event scheduled at %s" , self ._scheduled_events [0 ][0 ])
239
244
due_at : datetime = self ._scheduled_events [0 ][0 ]
240
245
self ._next_event_timer .reset (interval = due_at - datetime .now (timezone .utc ))
246
+ _logger .debug ("Next event scheduled at %s" , self ._scheduled_events [0 ][0 ])
241
247
242
248
def _remove_scheduled (self , dispatch : Dispatch ) -> bool :
243
249
"""Remove a dispatch from the scheduled events.
You can’t perform that action at this time.
0 commit comments