cd4c38
From d583a79750a7f3cf2c955d880ebfbfd5b8aa1675 Mon Sep 17 00:00:00 2001
cd4c38
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
cd4c38
Date: Thu, 2 Nov 2023 07:00:37 -0400
cd4c38
Subject: [PATCH] [Python] Do not call PyEval_InitThreads
cd4c38
MIME-Version: 1.0
cd4c38
Content-Type: text/plain; charset=UTF-8
cd4c38
Content-Transfer-Encoding: 8bit
cd4c38
cd4c38
Since Python 3.7, it’s called by Py_Initialize and doesn’t need to be called manually, so this removal has no effect.
cd4c38
cd4c38
Since Python 3.9, it does nothing, and in Python 3.13, it will be removed, which makes this change necessary.
cd4c38
cd4c38
References:
cd4c38
cd4c38
https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
cd4c38
cd4c38
https://github.com/python/cpython/issues/105182
cd4c38
---
cd4c38
 src/python/grpcio/grpc/_cython/cygrpc.pyx | 7 -------
cd4c38
 1 file changed, 7 deletions(-)
cd4c38
cd4c38
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx
cd4c38
index 2fd2347352a27..3b6ae9281139d 100644
cd4c38
--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx
cd4c38
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx
cd4c38
@@ -80,14 +80,7 @@ include "_cygrpc/aio/server.pyx.pxi"
cd4c38
 #
cd4c38
 # initialize gRPC
cd4c38
 #
cd4c38
-cdef extern from "Python.h":
cd4c38
-
cd4c38
-  int PyEval_InitThreads()
cd4c38
-
cd4c38
 cdef _initialize():
cd4c38
-  # We have Python callbacks called by c-core threads, this ensures the GIL
cd4c38
-  # is initialized.
cd4c38
-  PyEval_InitThreads()
cd4c38
   grpc_set_ssl_roots_override_callback(
cd4c38
           <grpc_ssl_roots_override_callback>ssl_roots_override_callback)
cd4c38