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

H

Heikki Salo

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.
 
D

Daniel Dittmar

Heikki said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top