time.sleep(1) sometimes runs for 200 seconds under windows

Scott David Daniels scott.daniels at acm.org
Fri Feb 24 11:20:44 EST 2006


Paul Probert wrote:
> Yes, I'm doing this:
>           .....
>          oldtime=time.time()
>          time.sleep(1)
>          newtime=time.time()
>          dt=newtime-oldtime
>           if dt > 2:
>               print 'dt=',dt,' time=',time.strftime('%Y_%m_%d_%Hh_%Mm_%Ss')
> Its happening roughly 4 times a day total on our 20 machines, ie about 
> once every 5 days on a given machine.

Well, you have a guess about the time updates that may well tell you
all.  Because of that guess, you might want to try:

           oldtime = time.time()
           time.sleep(1)
           newtime = time.time()
           delta = newtime - oldtime
           if not .5 < delta < 2:
               print 'delta=%s, from=%s, time=%s' % (
                   delta, time.strftime('%Y_%m_%d_%Hh_%Mm_%Ss',
                                        time.gmtime(oldtime)),
                   time.strftime('%Y_%m_%d_%Hh_%Mm_%Ss',
                                        time.gmtime(newtime)))

to see if you get time running backwards as well.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list