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

Claudio Grondi claudio.grondi at freenet.de
Thu Feb 23 19:26:14 EST 2006


Paul Probert wrote:
> 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
> 
With such rare occurrence it is very hard to tell what is going on. 
Usually I put such strange things on a list of curiosities I don't want 
to know the reason of, because it is in my eyes not worth the effort. 
Maybe it is even a common problem not yet detected by me, because I have 
never run this kind of tests for such a long time.
Starting today, I can tell you statistically not earlier than in one 
week, if I have the same problem on my machines (currently I am running 
only one or two at the same time).

In between let's try to use some logic:
If the machine and the operating system are not the cause, what have all 
these machines in common?
  1. The software they are running (kind of not often triggered bug)
  2. The network cards used (bug in hardware or drivers)
  3. Another piece of hardware common to all the machines
  3. The harddisks (recalibration)
  4. The network router/switch and/or the server.

Claudio



More information about the Python-list mailing list