Thread interruption
Laurent Pointal
laurent.pointal at wanadoo.fr
Fri Apr 27 15:17:07 EDT 2001
Joshua Marshall <jmarshal at mathworks.com> wrote in <9cc5ab$svr$1
@news.mathworks.com>:
>Yann Cointepas <yann.cointepas at chups.jussieu.fr> wrote:
>> Is there any portable ( Unix and Windows) way to interrupt a thread ?
>
>In Python, arbitrary threads aren't interruptible. As far as I know,
>the only thread you can interrupt is the main thread, by sending a
>signal to the process (in unix-land).
>
>The ability to interrupt arbitrary threads would be useful.
>
Hum, yes if it is at the Python level (by example by having the interpreter
cheking a thread interrupt indicator and raising an exception if it is set).
But if it is based on host threading system thread killing, we get into the
risk of unreleased resources (ex. leaving locked mutexs, reference counted
objects & Co).
With a python interpreter level interruption, the problem is for threads
which are locked at deeper level (waiting for file I/O, on select, on a
wait...). No many solutions, eventually 'hard' locking system could set an
'hard unlock' function which will be called when calling the Python
interrupt thread function/method.
A+
Laurent.
More information about the Python-list
mailing list