473,803 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

re-entrant call to PyEval_RestoreT hread(context) hangs

following hangs when re-entered

run()
{
PyEval_RestoreT hread(context);

pName = PyString_FromSt ring(script);

Py_DECREF(pName );

context = PyEval_SaveThre ad();
}

This invokes a python script (using context[0])

The python script uses "swig" to call back into the run() method
The run() method now calls PyEval_RestoreT hread(context[1])

but this hangs

ie to summarise

C++ run() context0
-> .py
-> C++ run() context1 HANGS!

Can anyone suggest a solution for this?
Jul 18 '05 #1
1 1783
On 26 Feb 2004 03:54:42 -0800, pc******@iel.ie (Paul) wrote:
following hangs when re-entered

run()
{
PyEval_RestoreT hread(context);

pName = PyString_FromSt ring(script);

Py_DECREF(pName );

context = PyEval_SaveThre ad();
}

This invokes a python script (using context[0])

The python script uses "swig" to call back into the run() method
The run() method now calls PyEval_RestoreT hread(context[1])

but this hangs

ie to summarise

C++ run() context0
-> .py
-> C++ run() context1 HANGS!

Can anyone suggest a solution for this?


I've never used SWIG, so I'm not sure if your run method is something for which
SWIG generates the actual C code or pseudocode you're using for example.
Anyway, if you're using 2.3, you can use the PyGILState API:

run()
{
PyGILState_STAT E state = PyGILState_Ensu re();

PyObject *pName = PyString_FromSt ring(script);

Py_XDECREF(pNam e);

PyGILState_Rele ase(state);
}

---
Greg Chapman

Jul 18 '05 #2

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

Similar topics

5
5495
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
1678
by: Steph | last post by:
Hi, Is it better to use the URL method to send informations to a page, or to use the context method ? Thanks.
4
1310
by: Hugo Flores | last post by:
Often people post questions about how did they loose their context between pages, and the more common cause is that they don't store the context on the viewstate upon postbacks. Mine is the other way around. Even though I don't fill the context object, I still get it after the Page Load event. May be I'm not understanding the context object quite well. Next is the code, and I know this wouldn't regularly transfer the context to the next...
5
2286
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or editor. I'd like to use the same default viewer/editor and open with... choices that are present on the users computer. Does anyone know how I can find this information programatically, so my picturebox context menu uses the same settings as the...
3
2041
by: tshad | last post by:
I am playing with GenericPrincipal classes and am using a sample program to test it. The problem is that even though I set the roles (which shows the roles in the Context.User as being there), when the program goes from the login page to the next page - the roles in the Context.User is empty. My Login page is: *****************************************************************
8
29837
by: rn5a | last post by:
I have a user control named Enter.ascx which has 2 TextBoxes. The 2 TextBoxes are named txt1 & txt2. The entire logic of this user control (like the properties of the 2 TextBoxes using set/get etc.) is encapsulated in a code behind page named Enter.ascx.vb. The code-behind also creates TextChanged events for the 2 TextBoxes. This is the code in Enter.ascx.vb: Namespace Details Public Class EnterCB : Inherits UserControl Public...
2
23113
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu on both views). What i'm struggling to do when the menuItem_Click event is fired, is to detect the TreeNode or ListViewItem that was originally right clicked when the context menu was opened. I can't just look at the selected item, because...
4
4216
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I choose, I want to be able to select several files, right click my mouse and launch an application which will act on the selected files. However, I don't even know where to start and have a number of questions!
20
310
by: Ryan Liu | last post by:
Hi, I have a client/server application, using one thread/client approach. I see very high context switch/sec. What are the ways to reduce it? Each thread sleep longer in its endless loop if not reducing thread? On the same machine, I also run a mysql server. I can see same amount thread in mysqld, seems mysql is also using one thread/client. But its context/swith is much lower. How can I get same performance?
4
11957
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the dialog box has as the default file name the name of this ashx file. I'd like to make that name more meaningfull but don't know how it gets set. I'm looking for a Response.Write but don't find one. Maybe that why the
0
9703
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...
0
9565
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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
9125
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...
0
6844
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
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2972
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.