Skip to content

Commit 1bd1750

Browse files
authored
Fixed incorrect Repeat.total_time_remaining. (#498) (#499)
* Fixed incorrect Repeat.total_time_remaining. * Changed Delay to return 0 instead of None for certain functions.
1 parent 4170f58 commit 1bd1750

File tree

1 file changed

+5
-7
lines changed
  • addons/source-python/packages/source-python/listeners

1 file changed

+5
-7
lines changed

Diff for: addons/source-python/packages/source-python/listeners/tick.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ def time_remaining(self):
181181
:rtype: float
182182
"""
183183
if not self.running:
184-
# TODO: what should we return here, or should we raise an error?
185-
return None
184+
return 0
186185
return self.exec_time - time.time()
187186

188187
@property
@@ -192,8 +191,7 @@ def time_elapsed(self):
192191
:rtype: float
193192
"""
194193
if not self.running:
195-
# TODO: what should we return here, or should we raise an error?
196-
return None
194+
return 0
197195
return time.time() - self._start_time
198196

199197
def _unload_instance(self):
@@ -314,10 +312,10 @@ def total_time_remaining(self):
314312
315313
:rtype: float
316314
"""
317-
if self.delay_time_remaining is None:
318-
return None
315+
if not self.delay_time_remaining:
316+
return 0
319317
return (
320-
self.loops_remaining * self.interval +
318+
(self.loops_remaining - 1) * self.interval +
321319
self.delay_time_remaining
322320
)
323321

0 commit comments

Comments
 (0)