accurate results, the problem is that, if I am not wrong, any signal
could terminate the sleep
sleep is an interruptible wait state so it can end early, but simple keyboard presses alone don't wake it.
however it's fine if the sleep ends early (or even does nothing) with that code - the "while" loop with the sleep call in it works fine even if sleep ends early. In fact the "wait_for_time_from_start" routine expects sleep to be very inaccurate - it only tries to use it for most of large wait periods and always after sleep returns. It does a "busy wait" (i.e. polls time taking up the CPU) to take care of small wait periods and finish off what sleep didn't.
is pygame.time.wait more accurate than time.sleep?
pygame.time.wait is very similar to time.sleep, they are nearly the same, they use the same approach, get the same accuracy and usually get the same precision as well (even though sleep lets you specify finer than a millisecond, it's actual precision less than millisecond on most platforms)