Python Forum
time.sleep works erratically, a bug in Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time.sleep works erratically, a bug in Python?
#3
Most popular PCs run an operating system that is non-deterministic which means you usually get decent timing but you never know when new threads or processes may override your program and slow it down. The only way to guarantee timing precision is to run your code with a real-time OS. There are many of them but they are mostly designed for embedded targets and FPGAs.

https://en.wikipedia.org/wiki/Comparison...ng_systems

Of course even those RT-OSes have limits but they can get you micro or nano second timing. There is a popular Linux option called RTLinux that will run on standard PC architecture if you need reliable timing and like Linux. Without a realtime OS you could try looking into Windows thread priority property or Linux's Nice command.
"So, brave knights, if you do doubt your courage or your strength, come no further, for death awaits you all with nasty, big, pointy teeth!" - Tim the Enchanter
Reply


Messages In This Thread
RE: time.sleep works erratically, a bug in Python? - by Marbelous - Jan-21-2020, 09:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use subprocess.Popen and time.sleep chucky831 2 1,960 Aug-11-2022, 07:53 PM
Last Post: carecavoador
  How to change UTC time to local time in Python DataFrame? SamKnight 2 1,616 Jul-28-2022, 08:23 AM
Last Post: Pedroski55
  How to immediately kill and restart a thread while using a time.sleep() inside it? philipbergwerf 4 3,557 Feb-07-2022, 04:16 PM
Last Post: Gribouillis
  Python Regular expression, small sample works but not on file Acernz 5 2,955 Jun-09-2021, 08:27 PM
Last Post: bowlofred
  Time.sleep: stop appending item to the list if time is early quest 0 1,884 Apr-13-2021, 11:44 AM
Last Post: quest
  Can you end the Time.sleep function boier96 9 9,498 Jan-16-2021, 10:09 PM
Last Post: Serafim
  "Automate the Boring Stuff with Python" creating a path works but only for CMD promt Milos 2 2,889 Nov-28-2020, 01:08 PM
Last Post: Larz60+
  time.sleep mtnwinds 4 2,879 May-21-2020, 10:12 AM
Last Post: Larz60+
  Works with Curl. Can't get it to work in Python bazcurtis 3 2,573 May-07-2020, 07:47 AM
Last Post: bazcurtis
  kill thread or process asap, even during time.sleep nanok66 4 2,939 Apr-29-2020, 10:13 AM
Last Post: nanok66

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020