Killing threads

VUG plugin at airtel.net
Thu Feb 28 12:11:48 CET 2002


Hi all. I'm doing an application in C who needs to execute simultaneous
Pythons scripts. Under certain conditions I need to kill one threads. ¿How
can I do it? For example, I have the following module:

------------------------- module.py
def func1():
    code......

def func2():
    code......

def func3():
    code......
-------------------------
Then, from de application in C I load the previous module and run one of the
functions as a thread, like this:

// Load the module
Py_Initialize();
PyRun_SimpleString("import thread");
PyRun_SimpleString("from module import *");
// Launch some threads
PyRun_SimpleString("thread.start_new_thead(func1,args)");
....
PyRun_SimpleString("thread.start_new_thead(func2,args)");


So.... How can I from the C code KILL one of the threads I have started?. I
know that I can use the exit() function from the thread but I need the user
who create these functions doesn't have to put this kind of code inside
their functions.

Thanks in advance






More information about the Python-list mailing list