c和python联编

问题遇到的现象和发生背景

c层创建的对象,python获取为空

这里为什么c层使用Init创建 agentMgr 对象,python层使用CreateAgent时,agentMgr 为NULL

问题相关代码,请勿粘贴截图
class CAgent
{
public:
    CAgent() {};
    ~CAgent() {};
};

class CAgentManager
{
public:
    CAgentManager() {};
    ~CAgentManager() {};
    CAgent* CreateAgent();
};

static CAgentManager* agentMgr = nullptr;
static void Init()
{
    agentMgr = new CAgentManager();
    cout << "111111111111111 Init " << agentMgr<<endl;
}

CAgent* CreateAgent()
{
    cout << "222222222222222 CreateAgent " << agentMgr;
    CAgent* agent = agentMgr->CreateAgent();
    return agent;
}

// 采用pybind11导出pyd文件进行调用
PYBIND11_MODULE(C_monster, m)
{
    m.def("Init", &Init);
    m.def("CreateAgent", &CreateAgent, py::return_value_policy::copy);
}

int main()
{
    Py_Initialize();
    Init();
    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.path.append('D:/Work/projects/C++/Test/test1/Scripts/')");
    PyObject* pModuleInit = PyImport_ImportModule("main");
    PyObject* pFuncInitGame = PyObject_GetAttrString(pModuleInit, "InitGame");
    PyObject_CallFunction(pFuncInitGame, NULL);
    Py_DECREF(pModuleInit);
    Py_DECREF(pFuncInitGame);
    Py_Finalize();
    system("pause");
    return 0;
}
import C_monster


def InitGame():
    print("InitGame")
    C_monster.CreateAgent()
运行结果及报错内容

111111111111111 Init 0000020D0F577EF0
InitGame
222222222222222 CreateAgent 0000000000000000

我的解答思路和尝试过的方法
我想要达到的结果

C_monster 是啥?

不太严格按照python扩展编写规范来写,官方有实例的。