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)
        print
        print 'Hehe !'

def main():
        print 'Starting two processes (press [Enter]): '
        raw_input()
        pid = os.fork()
        if (pid != 0):
                short_process(pid)
        else:
                long_process()

main()


On Nov 23, 2:30 am, Sorin Schwimmer <[EMAIL PROTECTED]> wrote:
> 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 variables
> and exit immediately.
>
> Thanks for your advice
> SxN
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to