diff --git a/34857.patch b/34857.patch new file mode 100644 index 0000000..38bb435 --- /dev/null +++ b/34857.patch @@ -0,0 +1,40 @@ +From 3100ba858cd47bb7fc2fa33cbf290fb6fd48372f Mon Sep 17 00:00:00 2001 +From: "Benjamin A. Beasley" +Date: Thu, 2 Nov 2023 07:00:37 -0400 +Subject: [PATCH] Do not call PyEval_InitThreads +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since Python 3.7, it’s called by Py_Initialize and doesn’t need to be called manually, so this removal has no effect. + +Since Python 3.9, it does nothing, and in Python 3.13, it will be removed, which makes this change necessary. + +References: + +https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads + +https://github.com/python/cpython/issues/105182 +--- + src/python/grpcio/grpc/_cython/cygrpc.pyx | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx +index 2fd2347352a27..3b6ae9281139d 100644 +--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx ++++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx +@@ -80,14 +80,7 @@ include "_cygrpc/aio/server.pyx.pxi" + # + # initialize gRPC + # +-cdef extern from "Python.h": +- +- int PyEval_InitThreads() +- + cdef _initialize(): +- # We have Python callbacks called by c-core threads, this ensures the GIL +- # is initialized. +- PyEval_InitThreads() + grpc_set_ssl_roots_override_callback( + ssl_roots_override_callback) + diff --git a/grpc.spec b/grpc.spec index 04546e3..ada5e1c 100644 --- a/grpc.spec +++ b/grpc.spec @@ -416,6 +416,9 @@ Patch: 0001-http2-Dont-drop-connections-on-metadata-limit-exceed.patch # https://github.com/grpc/grpc/issues/33918#issuecomment-1788823585 # https://github.com/grpc/grpc/pull/34242 Patch: 0001-Specify-noexcept-for-cdef-functions.patch +# Do not call PyEval_InitThreads +# https://github.com/grpc/grpc/pull/34857 +Patch: %{forgeurl}/pull/34857.patch Requires: grpc-data = %{version}-%{release}