[Tutor] how to run function only for a pre-defined time

Vinu Vikram vvinuv at gmail.com
Sat Oct 27 13:56:38 CEST 2007


Hi All
Could anybody try to tell me whether it is possible to run a function only
for a particular time period. In my python script I call some third party
function which some time won't give results. I would like to write the
script in such a way that, it will wait for the result from this function
for some time, say 10 seconds, and if it fails to get any results within
that time (10 seconds), the script should skip that function and stop the
program.

If I simplify more, how can I run an infinite loop (like in the bottom) only
for 10 seconds.

a=1
i=1
while a==1:
    print i
    i += 1

-- 
VINU VIKRAM
http://iucaa.ernet.in/~vvinuv/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071027/faa5b78c/attachment.htm 


More information about the Tutor mailing list