[patch] a patch to kill a thread in any OS

Aahz aahz at pythoncraft.com
Mon Feb 24 10:38:28 EST 2003


In article <mailman.1045698656.1301.python-list at python.org>,
anton wilson  <anton.wilson at camotion.com> wrote:
>
>In a previous thread last week, there was some discussion about
>killing a python thread by making it throw a SystemExit exception
>from within the interpreter loop. I've implemented it this way:
>
>1. Each thread gets a global tid number assigned by python when created
>   and passed to t_bootstate an argument
>2. Adding a new method thread.kill_thread(tid) to request that a thread 
>   die
>3. Make the thread.start_new() return the python assigned tid
>4. Adding a hashtable of threads to be killed that is checked every x   
>   bytecodes before it tries to release the GIL.If the tstate->id is in 
>   the hashtable, throw the SystemExit Exception. I've made the 
>   following patch for every OS, but it has only been tested on Linux.

Sounds interesting.  Submit the patch to SourceForge.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Register for PyCon now!  http://www.python.org/pycon/reg.html




More information about the Python-list mailing list