473,739 Members | 2,385 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 1779

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

Similar topics

7
7824
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
1662
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 applications stop running, that maybe the reason, but figure out yourself"?
0
1060
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
10192
by: PalB | last post by:
How to stop running multiple instances of my App in C#? Thanx
1
1296
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
2981
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 computer to make it work.. Can anybody help me trace where the problem is?? OR can anybody give me all...
3
2000
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
3504
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
11629
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
8969
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9269
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9211
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8216
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6756
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3282
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

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.