-
-
Notifications
You must be signed in to change notification settings - Fork 166
Add property to calculate and expose next run time of routine. #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,6 +330,22 @@ def start_time(self) -> Optional[datetime.datetime]: | |
| """ | ||
| return self._start_time | ||
|
|
||
| @property | ||
| def next_run(self) -> Optional[datetime.datetime]: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why it's |
||
| """Calculate and return the next run time of the routine.""" | ||
| now = datetime.datetime.now(datetime.timezone.utc) | ||
|
|
||
| if self._time: | ||
| next_run = self._time + datetime.timedelta(days=self._completed_loops) | ||
| if next_run < now: | ||
| next_run += datetime.timedelta(days=1) | ||
| elif self._delta: | ||
| next_run = self._start_time + datetime.timedelta(seconds=self._delta * (self._completed_loops + 1)) | ||
| if next_run < now: | ||
| next_run = now + datetime.timedelta(seconds=self._delta) | ||
|
|
||
| return next_run | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to check but this looks like it may have potential for next_run to never be defined. |
||
|
|
||
| def _can_be_cancelled(self) -> bool: | ||
| return self._task and not self._task.done() | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.