473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

re-entrant call to PyEval_RestoreThread(context) hangs

following hangs when re-entered

run()
{
PyEval_RestoreThread(context);

pName = PyString_FromString(script);

Py_DECREF(pName);

context = PyEval_SaveThread();
}

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_RestoreThread(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 1752
On 26 Feb 2004 03:54:42 -0800, pc******@iel.ie (Paul) wrote:
following hangs when re-entered

run()
{
PyEval_RestoreThread(context);

pName = PyString_FromString(script);

Py_DECREF(pName);

context = PyEval_SaveThread();
}

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_RestoreThread(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_STATE state = PyGILState_Ensure();

PyObject *pName = PyString_FromString(script);

Py_XDECREF(pName);

PyGILState_Release(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
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
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
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...
5
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...
3
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),...
8
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...
2
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...
4
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...
20
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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...

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.