Interrupting execution of PyRun_SimpleScript()

Andrew Dalke dalke at dalkescientific.com
Sun May 1 02:44:53 EDT 2005


A few days ago stephan wrote:
> Im am using PyRun_SimpleString() inside a BCB 5.0 GUI app
> on win32.

Never used it so can only offer a suggestion.
 
> For this I have a button called "stop", and when
> the user executes it, I generate an exeption by
> calling:
> PyRun_SimpleString("raise KeyboardInterrupt\n").

The fact that your GUI can call SimpleString implies
to me that Python is running with multiple threads.
The string is executed in a different thread from your
other thread.  The exception isn't being called from
the right thread.  Instead it's caught by the top-level
exception handler for the GUI, which reports the error.

Is it possible to put an explicit "check this variable
and if it's true then abort" in your time-intensive code?

				Andrew
				dalke at dalkescientific.com




More information about the Python-list mailing list