C++ and Python: how can I make it stop?

Daniel Dittmar daniel.dittmar at sap.com
Tue Dec 30 14:56:43 CET 2003


Heikki Salo wrote:
> I have decided to embedd Python into my C++ application and I have one
> question about it. Everything works perfectly, but I haven´t figured
> any way to stop the interpreter when it is executing (using
> PyRun_SimpleFile) a python script. I expose a callback-function (so
> scripts can call it) in my programs API which should stop the
> processing, but as I said, I have no idea how to do that. I tried to
> use sys.exit, but it kills the whole application.

Raise an exception in your callback (see
http://www.python.org/doc/current/api/exceptionHandling.html on how to do
this in C++).

Daniel







More information about the Python-list mailing list