Replace the current Timer
implementation to only use loop.time()
(not datetime
)
#77
Closed
leandro-lucarella-frequenz
started this conversation in
Ideas
Replies: 2 comments
-
Updated to keep using |
Beta Was this translation helpful? Give feedback.
0 replies
-
The new |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current timer implementation is like this:
This might have issues as it works with absolute wall time, so if there are changes in the wall clock the timer could fire in a time quite different to the requested
interval
.We could relay the timer handling toasyncio.loop.call_later()
which uses the monothonicloop.time()
.For a periodic timer (#78) we could see if(BTW,asyncio.loop.call_at()
is a better alternative, but we need to be careful and see what happens if the wall clock jumps around (daylight saving time, leap second, etc.).call_at
also uses the monotonic clock as the argument should be aasyncio.get_running_loop().time()
, not adatetime
).We should use
asyncio.get_running_loop().time()
instead ofdatetime.now()
. Also, I don't think we need to loop,sleep()
should be guaranteed to sleep for at least what it receives.I'm not sure why the current approach was used, probably something to discuss with @sahas-subramanian-frequenz
Beta Was this translation helpful? Give feedback.
All reactions