]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/PyModuleRegistry: do not call PyEval_InitThreads() on python3.9 38099/head
authorKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 07:33:42 +0000 (15:33 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 07:42:37 +0000 (15:42 +0800)
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 <kchai@redhat.com>
src/mgr/PyModuleRegistry.cc

index 5540339d6b0abde20dce63642a9a955ab45aeab1..2aa556cc9d51ece379f189340da7ba1867d69d31 100644 (file)
@@ -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();