Cross-platform time out decorator

Steve Holden steve at holdenweb.com
Thu Sep 27 11:54:30 EDT 2007


Joel wrote:
> On Sep 27, 4:36 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
>> Joel <joel.schae... at gmail.com> writes:
>>> I found the solution :
>>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440569
>>> describes a solution based on threads. I tested it and it works
>>> perfectly.
>> Note that, unlike the original alarm code, it doesn't really interrupt
>> the timed-out method, it just returns the control back to the caller,
>> using an exception to mark that a timeout occurred.  The "timed out"
>> code is still merrily running in the background.  I don't know if it's
>> a problem in your case, but it's an important drawback.
> 
> There should be a method to stop the thread though? I've never
> programmed thread stuff in python and wasn't able to find how to do
> it, would you happen to know how to "kill" the timed out thread?
> 
There is no way to "kill" a thread, other than set a flag and have the 
thread read it to realise the main thread wants it to stop.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list