I'm designed a small tool with MFC and python. 
In this program, I use C++ to cooperate with python API. 
I need: 

C++ function A calls Py_Initialize(), and then call python function B with Python API. 
In the python script Python function B starts a new python thread E, which will create a new file and make some output to this file. 
Then C++ function F calls Py_Finalize(). End. 

But things works unexpectedly. 
B can be called, but E will not start. After calling F, Py_Finalize() is called, then E will start and create the new file. 
I'm wondering what's wrong with this? It seems python is blocked by C++. Does this related with python GIL? If so, what should I do?
I solved the problem and would like to paste it here if someone else needs. 

After A calls Py_Initialize(), PyEval_InitThreads() is also needed. 
After A calls Python function B, GIL needs to be released by PyEval_ReleaseThread(PyThreadState_Get()). Then thread E can startup. 
After E is over, PyGILState_Ensure() should be called in C++ to get back the lock.
Create a new Thread in a python script, which is embeded in MFC