From 28985555f8557c297e15d68ff0ed5bd2868adc5e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 16 Nov 2020 15:33:42 +0800 Subject: [PATCH] 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 --- src/mgr/PyModuleRegistry.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index 5540339d6b0a..2aa556cc9d51 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(); -- 2.47.3