Re: Function stopping a function

2007-11-23 Thread Sorin Schwimmer
In my situation, there is a device with keyboard that allows some user input. In the same time, the device is connected to a standard PC, and there may be some communication there. The lengthy_function() resides and executes in the device, and so is cancel(). Lengthy_function() is pretty linear:

Re: Function stopping a function

2007-11-23 Thread [EMAIL PROTECTED]
Note, this only works in Unix systems: import os, signal def long_process(): while True: print "I'm messing with your terminal ! ", def short_process(long_process_id): raw_input('Press [Enter] to kill the bad process') os.kill(long_process_id, signal.SIGKILL) pr

Re: Function stopping a function

2007-11-23 Thread Duncan Booth
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):

Re: Function stopping a function

2007-11-22 Thread Sergio Correia
If you are talking about events and all that, I suppose you are using (or should be using) threads. Why don't try running the length_function as a Thread that on every loop checks a semaphore and if the condition is met, exits itself? Kinda like this: http://mail.python.org/pipermail/python-list/

Re: Function stopping a function

2007-11-22 Thread Donn Ingle
> 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. I would set a variable someplace (perhaps globally) that gets tested in lengthy_function()'s loop and issues

Function stopping a function

2007-11-22 Thread Sorin Schwimmer
Hi All, We all know that a function can launch the execution of another function. How can a function stop the execution of another function? For instance, lenghty_function() executes, when an external event triggers cancel(), which is supposed to abruptly stop lengthy_function(), reset some varia