471,579 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

How to stop a running embedded interpreter?

Hi!

I have embedded Python in an C++ App.
The Python-Interpreter is running in its own
Thread (I'm using PThreads).

I use PyRun_SimpleString to run Python-Code that the user entered
in an editorwindow.
I want the user to be able to stop the execution of
Python-Code (e.g. using a Cancel-Button).
Unfortunately I can't find a way to do this.

Of course, I can kill the Interpreter-Thread forcibly with
pthread_cancel() but the App will crash if I call any Python API-
Function afterwards.

I thought about starting 2 Threads in Python: One thread checks for a
stop condition (by calling a C-function that checks the Cancel-Button)
and the user-code runs in a second thread. The Problem with this
approach is that there seems to be no possibility for one Python-thread
to kill another.
I don't want the user to have to check fo a stop condition himself either.

Any help is greatly appreciated.

Regards,
Dirk
Sep 18 '06 #1
0 1599

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by lawrence | last post: by
6 posts views Thread by Perttu Pulkkinen | last post: by
reply views Thread by Tim Stanka | last post: by
1 post views Thread by Thomas Korimort | last post: by
bhing
1 post views Thread by bhing | last post: by
33 posts views Thread by Sunny | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.