-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add property to calculate and expose next run time of routine. #463
base: master
Are you sure you want to change the base?
Conversation
ea35ab5
to
fed7b25
Compare
Is this able to be merged now? I have had this running for a few weeks now without an issue by installing direct from my branch but would be good to get merged. |
@chillymosh can this be merged? |
I will test it now |
Ideally this would be a method, not a property. Logic after some testing works fine though |
@@ -330,6 +330,22 @@ def start_time(self) -> Optional[datetime.datetime]: | |||
""" | |||
return self._start_time | |||
|
|||
@property | |||
def next_run(self) -> Optional[datetime.datetime]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it's optional
? It doesn't appear the return would ever be optional
if next_run < now: | ||
next_run = now + datetime.timedelta(seconds=self._delta) | ||
|
||
return next_run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
Description
This PR adds a property
next_run
that calculates the next run time for the routine to the Routine class so that this can be exposed and used in other commands etc.I have tested this on my own production twitch bot by installing from git and it works great.
Checklist