thread, threading; how to kill a thread?

Jerry Sievers jerry at jerrysievers.com
Wed Nov 17 11:19:48 EST 2004


Greetings Pythonists;

I have limited experience with threaded apps and plenty with old style
forked heavyweight multi-processing apps.

Using Python 2.3.3 on a Redhat 7.x machine.

Wondering if there is a simple way from a main python program to kill
a running thread?  I see with the 'threading' module the way daemonic
threads behave when the main program finishes.

But suppose  we have a simple thread running a function like;

def timedLoop():
    while True:
        time.sleep(10)
        doSomething()

All I am trying to do is stop that thread immediatly from the main
program and it is unclear how to do this.  I see that using
del(threadObj) on the thread object that's running the loop function
does nothing.

Didn't notice anything obvious in the docs like a 'kill' method or
similar.  I don't necessarily want the main program to exit, just to
kill one or more threads.

Locks, conditions, semafores, signals?

ARG!  For heavens sake, what am I missing?

Thanks


-- 
-------------------------------------------------------------------------------
Jerry Sievers   305 854-3001 (home)     WWW ECommerce Consultant
                305 321-1144 (mobile    http://www.JerrySievers.com/



More information about the Python-list mailing list