Skip to content

Fixed incorrect Repeat.total_time_remaining. (#498) #499

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions addons/source-python/packages/source-python/listeners/tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ def time_remaining(self):
:rtype: float
"""
if not self.running:
# TODO: what should we return here, or should we raise an error?
return None
return 0
return self.exec_time - time.time()

@property
Expand All @@ -192,8 +191,7 @@ def time_elapsed(self):
:rtype: float
"""
if not self.running:
# TODO: what should we return here, or should we raise an error?
return None
return 0
return time.time() - self._start_time

def _unload_instance(self):
Expand Down Expand Up @@ -314,10 +312,10 @@ def total_time_remaining(self):

:rtype: float
"""
if self.delay_time_remaining is None:
return None
if not self.delay_time_remaining:
return 0
return (
self.loops_remaining * self.interval +
(self.loops_remaining - 1) * self.interval +
self.delay_time_remaining
)

Expand Down