[python-win32] Embedded Python and multithreading

Mark Hammond mhammond at skippinet.com.au
Thu Jun 26 10:55:11 CEST 2008


> 	PyThreadState* tcur = PyThreadState_Get() ;
> 
> 	PyThreadState_Swap(NULL);
> 	PyThreadState_Clear(tcur);
> 	PyThreadState_Delete(tcur);
> 
> 	// release the GIL as PyEval_InitThreads
> 	// implicitly acquires the GIL
> 	PyEval_ReleaseLock();
> 
> 	PyGILState_STATE gstate;

It's not necessary to do both the PyThreadState stuff *and* the PyGILState
stuff - just remove all the lines I quoted, except for the last, from both
callbacks and things should improve.

Cheers,

Mark



More information about the python-win32 mailing list