[EMAIL PROTECTED] wrote: > The first question is, I found out the API contains other commands lik > PyEval_AcquireLock(). I don't really understand if I have to use them > too, could anyone explain? Thanks.
That's unrelated. The GIL is special in that it has its own handling functions. > void MyProgressbar(Real p, void* hook) // this function wil be called > in another thread > { > PyGILState_STATE gilstate = PyGILState_Ensure(); > > PyObject* func = (PyObject*)hook; > //do some python stuff > > PyGILState_Release(gilstate) > } > > PyObject *pyMyFunction(PyObject *pSelf, PyObject *args, PyObject > *keywords) > { > static char *kwlist[] = {"hook", NULL}; > > PyObject *hook=NULL; > > if (!PyArg_ParseTupleAndKeywords(args, keywords, "O!", kwlist, > &PyFunction_Type, &hook)) > return NULL; You have to release the GIL around the following function call, so that the thread above can acuire it while you wait for the function to return in this thread here (which I assume you do). > LONG ok = MyFunction(myprogress, hook); //hook is a pointer which > is passed to the threaded function. Stefan -- http://mail.python.org/mailman/listinfo/python-list