Sorin Schwimmer <[EMAIL PROTECTED]> wrote:

> For instance, lenghty_function() executes, when an
> external event triggers cancel(), which is supposed to
> abruptly stop lengthy_function(), reset some variables
> and exit immediately.
> 

def lenghty_function(some, arguments, abort=lambda: False):
   while not abort():
      do some part of the function


then you just pass in whatever abort function is appropriate: it can check 
some flag to see whether the function should continue, or it might just 
check the current time and return True if the function has been going too 
long.
Just make sure that the badly spelled function calls abort() often.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to