Skip to content

Commit 6b290ac

Browse files
committed
timing_tools.py: Decrease Logging More - 2
1 parent 0b73e8c commit 6b290ac

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

wipac_dev_tools/timing_tools.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ async def wait_until_interval(
5757
)
5858

5959
for i in itertools.count():
60-
if self.has_interval_elapsed(do_log=self._is_nth(i, log_every_nth)):
60+
if self.has_interval_elapsed():
6161
return
62+
if self.logger and self._is_nth(i, log_every_nth):
63+
self.logger.debug(f"Still waiting for {self.seconds}s interval...")
6264
await asyncio.sleep(frequency)
6365

6466
def wait_until_interval_sync(
@@ -77,21 +79,19 @@ def wait_until_interval_sync(
7779
)
7880

7981
for i in itertools.count():
80-
if self.has_interval_elapsed(do_log=self._is_nth(i, log_every_nth)):
82+
if self.has_interval_elapsed():
8183
return
84+
if self.logger and self._is_nth(i, log_every_nth):
85+
self.logger.debug(f"Still waiting for {self.seconds}s interval...")
8286
time.sleep(frequency)
8387

84-
def has_interval_elapsed(self, do_log: bool = True) -> bool:
88+
def has_interval_elapsed(self) -> bool:
8589
"""Check if the specified time interval has elapsed since the last expiration.
8690
8791
If the interval has elapsed, the internal timer is reset to the current time.
8892
"""
8993
diff = time.monotonic() - self._last_time
9094
if diff >= self.seconds:
9195
self._last_time = time.monotonic()
92-
if self.logger and do_log:
93-
self.logger.debug(
94-
f"Interval elapsed: {self.seconds}s (actual: {diff:.3f}s)."
95-
)
9696
return True
9797
return False

0 commit comments

Comments
 (0)