Prev: Sorting a list with entries of unequal types
Next: Some C-API functions clear the error indicator?
From: Richard Lamboj on 28 Jan 2010 08:25 Hello, which Method is better to kill a Thread? Using Thread Events, or a raising a Exception? Maybe someone has a small example for me? Kind Regards, Richi
From: Gabriel Genellina on 29 Jan 2010 16:17 En Thu, 28 Jan 2010 10:25:30 -0300, Richard Lamboj <richard.lamboj(a)bilcom.at> escribi�: > which Method is better to kill a Thread? Using Thread Events, or a > raising a > Exception? Maybe someone has a small example for me? The best way is simply NOT to do that. You don't kill a thread, you ask it to commit suicide. There is no reliable way to forcefully shut down another thread. The thread must periodically check some value (perhaps an Event object; in simple cases any variable will do) and (cleanly) exit when asked to. Threads that run pure Python code may be interrupted using the API call PyThreadState_SetAsyncExc; look for a recipe using ctypes to call it from Python. -- Gabriel Genellina
|
Pages: 1 Prev: Sorting a list with entries of unequal types Next: Some C-API functions clear the error indicator? |