[Tutor] timeout

Kent Johnson kent37 at tds.net
Mon Jan 16 15:01:37 CET 2006


If you just want a delay, as your empty loop pseudocode seems to do, use 
time.sleep() as Wim suggested.

If you are processing in a loop and you want to stop processing after a 
certain amount of time, you could check time.time() each time through 
the loop and end when the allotted time has elapsed.

If you want to abort the loop from outside the loop, it's a harder 
problem...

Kent

frank h. wrote:
> Hello
> how can I break a loop after a certain amount of time has passed?
> 
> pseudocode:
> 
> with timeout of 60sec:
>     while True:
>         pass
> 
> is there a simple way? without resorting to queues etc. (this is a bit
> over my head....)
> thanks for any insight you might have
> -frank
> 
> 
> On 1/16/06, frank h. <frank.hoffsummer at gmail.com> wrote:
> 
>>Hello
>>how can I break a loop after a certain amount of time has passed?
>>
>>pseudocode:
>>
>>with timeout of 60sec:
>>
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 




More information about the Tutor mailing list