473,587 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_SimpleStr ing 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 1767

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7814
by: lawrence | last post by:
Suppose I create dynamic web pages with 3 functions (which call other functions to make everything happen, but these 3 you might think of as being the top layer): registerSessions(); sendHtmlToBrowsers(); incrementPageViews(); Is there any chance that incrementPageViews() will be executed? Or, to
6
1655
by: Perttu Pulkkinen | last post by:
I just want to ask php-community, are they running too fast with new versions. Why: 1) Its not so nice to load 4.2x and then come back couople of months later to find out that php 5 is out while you're still making yourself familiar with 4.2x. 2) Are webhosters happy to announce their clients "btw, we have installed new version, if your...
0
1057
by: Tim Stanka | last post by:
Hello, I have created a Python class with a Write() function which grabs stdout from the embedded interpreter and appends onto to the text already in a CEdit multiline control with the help of a C++ extension. I was curious if there was a way to grab stdout via the C-API? Thanks, Tim
4
10155
by: PalB | last post by:
How to stop running multiple instances of my App in C#? Thanx
1
1290
by: Thomas Korimort | last post by:
Hi! I have embedded a Python interpreter into a C++ framework. When running some Python code in the interpreter, how can i get a traceback with line number file..., when an exception occurs? Greetings, Thomas Korimort.
1
2973
bhing
by: bhing | last post by:
hiya!!! Im assigned to a website where jsp,mysql, and tomcat is used which runs on fedora 5. NOw i wonder why sometimes the tomcat will stop running, so i have to restart it again to keep the website up and running. BUt that's not only the problem because sometimes even if i already restarted the tomcat, nothing happens, so i restarted the...
3
1982
by: ycollet | last post by:
Hello, I've written a C embedded application. I want to open a python gui application in my C program but when I do : PyRun_String( "import gui.py", file_input, pDictionary, pDictionary ); the interpreter emits an error: tkinter module not defined What script must I load to initialize the embedded python interpreter
1
3499
by: pssheba | last post by:
Hi, My sp creates an error report. at a certain stage i want it to stop running if there are errors in thar report. I wrote: DECLARE @myparam INTEGER SELECT @myparam=COUNT(*) FROM report_errors1 IF (@myParam>0) BEGIN print 'stop running due to existing errors ! '
33
11607
by: Sunny | last post by:
Hi, Sometime, when your script is too big, IE Gives you a warning "Stop Running This Script" A script on this page is causing Internet Explorer to run slowly. Does anyone knows, How to correct that? Thanks.
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.