Is there a better way to implement this:

Peter Otten __peter__ at web.de
Tue Jan 23 03:13:21 EST 2007


Paul Boddie wrote:

> Michael Yanowitz wrote:
>>
>>    I guess I am looking for something portable (both
>> Windows and Linux) where I can abort a function after
>> a certain time limit expires.
> 
> Doing a search for "timeout function Python" on Google reveals a number
> of approaches.
 
> Using threads:
> 
>   * http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878

That doesn't abort the calculation, however -- it just moves on with a
default value instead of the actual result if that is not available after
the specified timespan. 

The calculation may go on forever eating up resources.

Peter



More information about the Python-list mailing list