No subject
Sat Oct 23 05:29:24 CEST 2004
Assuming you have access to an interpreter object, the typical idiom for
calling into Python from a C thread is
PyThreadState *tstate;
PyObject *result;
/* interp is your reference to an interpreter object. */
tstate = PyThreadState_New(interp);
PyEval_AcquireThread(tstate); /* this locks the GIL */
/* Perform Python actions here. */
result = CallSomeFunction();
/* evaluate result */
/* Release the thread. No Python API allowed beyond this point. */
PyEval_ReleaseThread(tstate); /* this unlocks the GIL */
/* You can either delete the thread state, or save it
until you need it the next time. */
PyThreadState_Delete(tstate);
Simon.
More information about the Pyrex
mailing list