I'm using wxpython and threading module of python to build a simple timer with GUI. I used time.slee(0.5) to measure the time. The problem is: Once I start the timer and switch to other program like chrome. Some times later when I switched back, the time displayed on my timer is very inaccurate. For example, if I set 3 minutes to run, it turns out that my timer is 3 times slower than the operating system clock.
After searching, I know that time.sleep() is unreliable, but it seems the gap is so huge that makes me doubt if there is something wrong.
I also noticed that If I don't put the script into background, then there is only 2-3 seconds difference.
I can accept several seconds difference, but not 2 "minutes".How can I solve it?