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

Paul Probert pprobert at wisc.edu
Thu Feb 23 17:12:17 EST 2006


Peter Hansen wrote:

>Are you saying that you believe the time.sleep(1) call is actually 
>blocking for 200 seconds?  Or just that your loop (and we can only guess 
>what it looks like) is the one taking that long?
>
>If the former, try something like putting "print 'before'" and "print 
>'after'" before and after the sleep, and observe what happens when you 
>run the program.  I'm fairly confident in saying there's no chance 
>you'll see the "before" sit for 200s before you see the "after" and that 
>your problem lies elsewhere, not with time.sleep(1).
>
>If the latter, um, obviously we can't help without more info.
>
>-Peter
>
>  
>
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.

Paul Probert
University of Wisconsin




More information about the Python-list mailing list