aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio
diff options
context:
space:
mode:
authorGravatar Masood Malekghassemi <atash@google.com>2016-07-13 16:57:31 -0700
committerGravatar Masood Malekghassemi <atash@google.com>2016-07-13 16:57:57 -0700
commite9b90e5e1f8183fd0259ae8ccc9735fb8027fe20 (patch)
tree0c61e7ac7a4720e006bdb6a4b084870ad91f1ee5 /src/python/grpcio
parent85fa79d228e6b5167f9f0148567e0c183f6b82a4 (diff)
Move Python.h include out of loader code
To make a certain private code base work in a certain way nicer than the current way.
Diffstat (limited to 'src/python/grpcio')
-rw-r--r--src/python/grpcio/grpc/_cython/cygrpc.pyx9
-rw-r--r--src/python/grpcio/grpc/_cython/loader.c3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx
index e055d321bc..2fc8e16461 100644
--- a/src/python/grpcio/grpc/_cython/cygrpc.pyx
+++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx
@@ -49,6 +49,11 @@ include "grpc/_cython/_cygrpc/server.pyx.pxi"
#
+cdef extern from "Python.h":
+
+ int Py_AtExit(void(*func)())
+
+
def _initialize():
if not pygrpc_initialize_core():
raise ImportError('failed to initialize core gRPC library')
@@ -56,4 +61,8 @@ def _initialize():
grpc_set_ssl_roots_override_callback(
<grpc_ssl_roots_override_callback>ssl_roots_override_callback)
+ if Py_AtExit(grpc_shutdown) != 0:
+ raise ImportError('failed to register gRPC library shutdown callbacks')
+
+
_initialize()
diff --git a/src/python/grpcio/grpc/_cython/loader.c b/src/python/grpcio/grpc/_cython/loader.c
index 34bd897549..4698f0aff8 100644
--- a/src/python/grpcio/grpc/_cython/loader.c
+++ b/src/python/grpcio/grpc/_cython/loader.c
@@ -31,7 +31,6 @@
*
*/
-#include <Python.h>
#include "loader.h"
#ifdef __cplusplus
@@ -43,7 +42,7 @@ int pygrpc_load_core(char *path) { return 1; }
// Cython doesn't have Py_AtExit bindings, so we call the C_API directly
int pygrpc_initialize_core(void) {
grpc_init();
- return Py_AtExit(grpc_shutdown) < 0 ? 0 : 1;
+ return 1;
}
#ifdef __cplusplus