From: Kefu Chai Date: Mon, 16 Nov 2020 07:33:42 +0000 (+0800) Subject: mgr/PyModuleRegistry: do not call PyEval_InitThreads() on python3.9 X-Git-Tag: v16.1.0~581^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38099%2Fhead;p=ceph.git mgr/PyModuleRegistry: do not call PyEval_InitThreads() on python3.9 PyEval_InitThreads() and PyEval_ThreadsInitialized() are deprecated since python3.9, and GIL is initialized by Py_Initialize() in python3.9. so do not call them unless we are using python < 3.9. see https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads Signed-off-by: Kefu Chai --- diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index 5540339d6b0..2aa556cc9d5 100644 --- a/src/mgr/PyModuleRegistry.cc +++ b/src/mgr/PyModuleRegistry.cc @@ -60,13 +60,13 @@ void PyModuleRegistry::init() } PyImport_AppendInittab("ceph_module", PyModule::init_ceph_module); Py_InitializeEx(0); - +#if PY_VERSION_HEX < 0x03090000 // Let CPython know that we will be calling it back from other // threads in future. if (! PyEval_ThreadsInitialized()) { PyEval_InitThreads(); } - +#endif // Drop the GIL and remember the main thread state (current // thread state becomes NULL) pMainThreadState = PyEval_SaveThread();