[Python.NET] How to interrupt Python from a .NET program?

Michael.Gogins at sungard.com Michael.Gogins at sungard.com
Thu Feb 5 17:30:20 EST 2004

I have written a Python script editor in C#. It runs a script using PythonEngine.RunSimpleString().

I need to be able to interrupt the script execution fromC#, but I haven't been able to figure out how to do it without crashing the process.

If I try to finalize the PythonEngine, or raise a keyboard interrupt, either in the GUI thread, or in a Python callback thread (a C# delegate), I get:

Fatal Python error: PyThreadState_Get: no current thread

Thanks for any light anyone can shed on this.

More information about the PythonDotNet mailing list