#Exact time interval using "time.sleep"
Python , module , method , precise , interval time , time.sleep , threading , queue , matplotlib FuncAnimation , update
We often use "time.sleep" in our measurements, but "time.sleep" gives us the approximate time requested, but not the exact time. Here, it provides a software to set the time interval precisely by adjusting the sleep period using "time.sleep".
[!TIPS]
- The default system clock tickon a Windows OS is 15.625 msec -- 1/64 second. So that is the degree of time accuracy.
Case#1 is when using "time.sleep" , "threading", and "queue".1 I'll adjust the "time.sleep" period at the end of a series of threading processes. It is processing at every one second.
Case#2 is when not using "threading". For example, when using "matplotlib FuncAnimation" method. "FuncAnimation" calls a time interval, which cannot be changed, but "FuncAnimation" also calls an "external update function", and in that function you can adjust a time interval using "time.sleep" method.
- PC: windows PC
- OS: Windows11
- Python: Version 3.9.13
- Libraries: numpy, matplotlib
- None