Embedding Python in a multi-threaded C++ application
Mustafa Demirhan
mustafademirhan at gmail.com
Tue Nov 9 16:20:33 EST 2004
The problem is that I cannot access the thread that needs to be
terminated because that thread is the problematic one - it is doing
something intensive or it is hang up in some Python code. When I call
PyErr_SetInterrupt() from the main thread, nothing happens. All the
other threads continue working.
Is there any way that I stop one thread that is running a python code
from my main thread? I am thinking of posting messages to the running
thread, but I dont think that running thread will ever process the
message before it finishes executing its python code.
Best wishes,
Mustafa Demirhan
On Tue, 9 Nov 2004 14:21:23 -0600, Jeff Epler <jepler at unpythonic.net> wrote:
> Perhaps you can use PyErr_SetInterrupt() to create a KeyboardInterrupt
> in the Python thread.
>
> void PyErr_SetInterrupt( )
> This function simulates the effect of a SIGINT signal arriving
> -- the next time PyErr_CheckSignals() is called,
> KeyboardInterrupt will be raised. It may be called without
> holding the interpreter lock.
>
> There's no way to "clean up" after Python if you terminate its
> thread---Python's datastructures could be in an inconsistent state, so
> just releasing a lock wouldn't do you any good.
>
> Jeff
>
>
>
--
Mustafa Demirhan
More information about the Python-list
mailing list