I was playing around with the time.sleep function from python\'s standard library and found it inadequate for sub-ms delays. From testing I found it to actually wait 1.1-1.2
This is sort of a duplicate question, but I'll try to answer it here anyway to the best of my ability.
The sleep function is an OS call that differs from busy wait in that it doesn't block the thread. If you have a multi-threaded script though, it shouldn't block the other threads.
The sleep function is inaccurate in Windows because it is not a realtime OS (not sure what that means). If you are looking strictly for accuracy of the wait, busy wait is the way to go. Otherwise, time.sleep()
is probably preferred. The reason the OS call to sleep is inaccurate is probably because it relies on the OS to return at the correct time, and is reliant on the precision of the OS's scheduler.