Stopping a thread from another one

Fabiano Sidler fabianosidler at my-mail.ch
Tue Jun 22 20:39:18 EDT 2004


Hello Newsgroup!

In my Python script, I use the 'thread' module (not 'threading') and 
'signal' simultaneously. All spawned threads execute 
'pcapObject.loop(-1, callback)', which does not return.

The problem now is:
When the script catch a signal (let's say: SIGHUP), only the main thread 
is affected. But I need also the subthreads to be ended, because the 
script reopen()s files on SIGHUP and would also re-create the threads.

NOT a solution is:
The main thread sets a lock in the signal handler, the pcap-callback()
function examines this lock everytime it's called, and if set, exit()s 
the thread. This is not very beautiful.
I would prefer, if I end the subthreads by the main thread.
Is there any chance?

Greetings,
fps



More information about the Python-list mailing list