threads and exception in wxPython
Peter Hansen
peter at engcorp.com
Wed Nov 3 13:50:20 EST 2004
Nick Craig-Wood wrote:
> Peter Hansen <peter at engcorp.com> wrote:
>
>> >>> t = T()
>> >>> t
>><T(Thread-7, started)>
>> >>> asyncexc = ctypes.pythonapi.PyThreadState_SetAsyncExc
>> >>> exc = ctypes.py_object(ValueError)
>> >>> asyncexc(t.id, exc)
>> 1
>> >>> thread terminated!
>>
>> >>> t
>><T(Thread-7, stopped)>
>
>
> On a related subject, I'm trying to forcibly terminate a thread thats
> already running. I don't see any means of doing this in the docs.
> Sending it an exception would be ideal. Is the above the only way of
> doing this?
This isn't just a related subject, this is exactly what
I was trying to do above.
I have a test case here which is failing, however, because
the exception is *not* being delivered asynchronously for
some reason, but appears in the thread only when the thread
is already terminating itself. I'm still experimenting, but
I will probably post the failing test case shortly for
others to play with.
Nick, if you want to learn more, read the threads from this
google search: http://groups.google.ca/groups?q=PyThreadState_SetAsyncExc
Then you'll know as much as anyone about this...
-Peter
More information about the Python-list
mailing list