By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,616 Members | 1,618 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,616 IT Pros & Developers. It's quick & easy.

re-entrant call to PyEval_RestoreThread(context) hangs

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.