From e861546b3cc9f5daa1380327c28068365e8b42b6 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 7 Oct 2020 17:22:57 -0700 Subject: [PATCH] Replace grpc_shutdown_blocking with grpc_shutdown in Cython --- .../grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi | 4 ++-- src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi | 2 +- .../grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi | 2 +- .../grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | 8 ++++---- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 1 + .../grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi | 6 +++--- src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi index 06c92cac586..9aec95520fb 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi @@ -94,7 +94,7 @@ def _grpc_shutdown_wrapper(_): Define functions are not allowed in "cdef" functions, and Cython complains about a simple lambda with a C function. """ - grpc_shutdown_blocking() + grpc_shutdown() cdef _actual_aio_shutdown(): @@ -106,7 +106,7 @@ cdef _actual_aio_shutdown(): future.add_done_callback(_grpc_shutdown_wrapper) elif _global_aio_state.engine is AsyncIOEngine.POLLER: (_global_aio_state.cq).shutdown() - grpc_shutdown_blocking() + grpc_shutdown() else: raise ValueError('Unsupported engine type [%s]' % _global_aio_state.engine) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi index bdd155bea94..f68e166b17a 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi @@ -86,7 +86,7 @@ cdef class Call: with nogil: if self.c_call != NULL: grpc_call_unref(self.c_call) - grpc_shutdown_blocking() + grpc_shutdown() # The object *should* always be valid from Python. Used for debugging. @property diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 74c7f6c1405..ebffb7b0a25 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -425,7 +425,7 @@ cdef _close(Channel channel, grpc_status_code code, object details, _destroy_c_completion_queue(state.c_connectivity_completion_queue) grpc_channel_destroy(state.c_channel) state.c_channel = NULL - grpc_shutdown_blocking() + grpc_shutdown() state.condition.notify_all() else: # Another call to close already completed in the past or is currently diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi index a47403ac51c..54c55f85f12 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi @@ -115,4 +115,4 @@ cdef class CompletionQueue: self.c_completion_queue, c_deadline, NULL) self._interpret_event(event) grpc_completion_queue_destroy(self.c_completion_queue) - grpc_shutdown_blocking() + grpc_shutdown() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index c75579cc04f..b1d0a8b2f4a 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -58,7 +58,7 @@ cdef int _get_metadata(void *state, cdef void _destroy(void *state) except * with gil: cpython.Py_DECREF(state) - grpc_shutdown_blocking() + grpc_shutdown() cdef class MetadataPluginCallCredentials(CallCredentials): @@ -124,7 +124,7 @@ cdef class SSLSessionCacheLRU: def __dealloc__(self): if self._cache != NULL: grpc_ssl_session_cache_destroy(self._cache) - grpc_shutdown_blocking() + grpc_shutdown() cdef class SSLChannelCredentials(ChannelCredentials): @@ -190,7 +190,7 @@ cdef class ServerCertificateConfig: def __dealloc__(self): grpc_ssl_server_certificate_config_destroy(self.c_cert_config) gpr_free(self.c_ssl_pem_key_cert_pairs) - grpc_shutdown_blocking() + grpc_shutdown() cdef class ServerCredentials: @@ -206,7 +206,7 @@ cdef class ServerCredentials: def __dealloc__(self): if self.c_credentials != NULL: grpc_server_credentials_release(self.c_credentials) - grpc_shutdown_blocking() + grpc_shutdown() cdef const char* _get_c_pem_root_certs(pem_root_certs): if pem_root_certs is None: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index a7131355a07..b873bb0676f 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -334,6 +334,7 @@ cdef extern from "grpc/grpc.h": grpc_op_data data void grpc_init() nogil + void grpc_shutdown() nogil void grpc_shutdown_blocking() nogil int grpc_is_initialized() nogil diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi index 0f693ec6911..d857317ead0 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi @@ -39,7 +39,7 @@ cdef class SocketWrapper: self.len = 0 def __dealloc__(self): - grpc_shutdown_blocking() + grpc_shutdown() cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil: sw = SocketWrapper() @@ -267,7 +267,7 @@ cdef class ResolveWrapper: self.c_port = NULL def __dealloc__(self): - grpc_shutdown_blocking() + grpc_shutdown() cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper): try: @@ -323,7 +323,7 @@ cdef class TimerWrapper: self.timer.stop() def __dealloc__(self): - grpc_shutdown_blocking() + grpc_shutdown() cdef void timer_start(grpc_custom_timer* t) with gil: timer = TimerWrapper(t.timeout_ms / 1000.0) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 308d677695f..05db7e3df9f 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -137,7 +137,7 @@ cdef class CallDetails: def __dealloc__(self): with nogil: grpc_call_details_destroy(&self.c_details) - grpc_shutdown_blocking() + grpc_shutdown() @property def method(self): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index eff95c4f299..48014b68804 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -154,4 +154,4 @@ cdef class Server: def __dealloc__(self): if self.c_server == NULL: - grpc_shutdown_blocking() + grpc_shutdown()