@@ -57,8 +57,10 @@ async def wait_until_interval(
57
57
)
58
58
59
59
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 ():
61
61
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..." )
62
64
await asyncio .sleep (frequency )
63
65
64
66
def wait_until_interval_sync (
@@ -77,21 +79,19 @@ def wait_until_interval_sync(
77
79
)
78
80
79
81
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 ():
81
83
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..." )
82
86
time .sleep (frequency )
83
87
84
- def has_interval_elapsed (self , do_log : bool = True ) -> bool :
88
+ def has_interval_elapsed (self ) -> bool :
85
89
"""Check if the specified time interval has elapsed since the last expiration.
86
90
87
91
If the interval has elapsed, the internal timer is reset to the current time.
88
92
"""
89
93
diff = time .monotonic () - self ._last_time
90
94
if diff >= self .seconds :
91
95
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
- )
96
96
return True
97
97
return False
0 commit comments