]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind: remove deprecated PyEval_InitThreads() calls 66508/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 4 Dec 2025 10:17:25 +0000 (18:17 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 4 Dec 2025 10:23:04 +0000 (18:23 +0800)
commitf261379edcd9128aa5c120d9eca269341b632f68
tree31133e6bc740f7f58ec377e092750129d8509e7e
parent8611241dc028e3b148e236f6c5d350f9f0381cb1
pybind: remove deprecated PyEval_InitThreads() calls

Remove all calls to PyEval_InitThreads(), which has been deprecated since
Python 3.9 and generates compiler warnings on Python 3.13+.

Background:
-----------
PyEval_InitThreads() was used to initialize Python's GIL (Global Interpreter
Lock) and threading support. In Python 3.7+, the GIL is automatically
initialized, making this function a no-op.

From Python 3.9 source (Python/ceval.c:315-318):
  void PyEval_InitThreads(void)
  {
      /* Do nothing */
  }

The function was officially deprecated in Python 3.9:
https://docs.python.org/3/whatsnew/3.9.html
  "Deprecated: PyEval_InitThreads() and PyEval_ThreadsInitialized()
   are now deprecated and will be removed in Python 3.13."

As of Python 3.13, calling this function produces deprecation warnings:
  warning: 'PyEval_InitThreads' is deprecated [-Wdeprecated-declarations]

Rationale:
----------
Ceph enforces a minimum Python version of 3.9 (CMakeLists.txt:630):
  if(Python3_VERSION VERSION_LESS 3.9)
    message(FATAL_ERROR "... please use Python 3.9 and up")

Since we require Python 3.9+, and PyEval_InitThreads() is a no-op in
Python 3.9+, these calls serve no purpose and can be safely removed.

Changes:
--------
- Removed PyEval_InitThreads() declaration from cdef extern blocks
- Removed PyEval_InitThreads() calls from __init__/__cinit__ methods

Affected files:
- src/pybind/rados/rados.pyx (Rados.__init__)
- src/pybind/rgw/rgw.pyx (LibRGWFS.__cinit__)
- src/pybind/cephfs/cephfs.pyx (LibCephFS.__cinit__)

References:
- Python 3.9 source: https://github.com/python/cpython/blob/3.9/Python/ceval.c#L315-L318
- Python 3.9 What's New: https://docs.python.org/3/whatsnew/3.9.html
- Python 3.13 deprecation: https://docs.python.org/3.13/c-api/init.html#c.PyEval_InitThreads

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/pybind/cephfs/cephfs.pyx
src/pybind/rados/rados.pyx
src/pybind/rgw/rgw.pyx