Skip to content

Its-OK-Wakamatsu-san/Exact_time_interval_using_-time.sleep-

Repository files navigation

#Exact time interval using "time.sleep"

Keyword

Python , module , method , precise , interval time , time.sleep , threading , queue , matplotlib FuncAnimation , update

Overview

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]

  1. 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

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#1

Case#2

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.

Case#2

Hardware Environment

  1. PC: windows PC

Software Environment

  1. OS: Windows11
  2. Python: Version 3.9.13
  3. Libraries: numpy, matplotlib

Known issue

  1. None

Rerated Webpages

Footnotes

  1. How to run and verify periodically in Python, described in Japanese)

About

Exact time interval using "time.sleep"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages