Replace grpc_shutdown_blocking with grpc_shutdown in Cython

pull/24363/head
Lidi Zheng 4 years ago
parent bba8facb4a
commit e861546b3c
  1. 4
      src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi
  2. 2
      src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
  3. 2
      src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
  4. 2
      src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi
  5. 8
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
  6. 1
      src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
  7. 6
      src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx.pxi
  8. 2
      src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
  9. 2
      src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi

@ -94,7 +94,7 @@ def _grpc_shutdown_wrapper(_):
Define functions are not allowed in "cdef" functions, and Cython complains Define functions are not allowed in "cdef" functions, and Cython complains
about a simple lambda with a C function. about a simple lambda with a C function.
""" """
grpc_shutdown_blocking() grpc_shutdown()
cdef _actual_aio_shutdown(): cdef _actual_aio_shutdown():
@ -106,7 +106,7 @@ cdef _actual_aio_shutdown():
future.add_done_callback(_grpc_shutdown_wrapper) future.add_done_callback(_grpc_shutdown_wrapper)
elif _global_aio_state.engine is AsyncIOEngine.POLLER: elif _global_aio_state.engine is AsyncIOEngine.POLLER:
(<PollerCompletionQueue>_global_aio_state.cq).shutdown() (<PollerCompletionQueue>_global_aio_state.cq).shutdown()
grpc_shutdown_blocking() grpc_shutdown()
else: else:
raise ValueError('Unsupported engine type [%s]' % _global_aio_state.engine) raise ValueError('Unsupported engine type [%s]' % _global_aio_state.engine)

@ -86,7 +86,7 @@ cdef class Call:
with nogil: with nogil:
if self.c_call != NULL: if self.c_call != NULL:
grpc_call_unref(self.c_call) grpc_call_unref(self.c_call)
grpc_shutdown_blocking() grpc_shutdown()
# The object *should* always be valid from Python. Used for debugging. # The object *should* always be valid from Python. Used for debugging.
@property @property

@ -425,7 +425,7 @@ cdef _close(Channel channel, grpc_status_code code, object details,
_destroy_c_completion_queue(state.c_connectivity_completion_queue) _destroy_c_completion_queue(state.c_connectivity_completion_queue)
grpc_channel_destroy(state.c_channel) grpc_channel_destroy(state.c_channel)
state.c_channel = NULL state.c_channel = NULL
grpc_shutdown_blocking() grpc_shutdown()
state.condition.notify_all() state.condition.notify_all()
else: else:
# Another call to close already completed in the past or is currently # Another call to close already completed in the past or is currently

@ -115,4 +115,4 @@ cdef class CompletionQueue:
self.c_completion_queue, c_deadline, NULL) self.c_completion_queue, c_deadline, NULL)
self._interpret_event(event) self._interpret_event(event)
grpc_completion_queue_destroy(self.c_completion_queue) grpc_completion_queue_destroy(self.c_completion_queue)
grpc_shutdown_blocking() grpc_shutdown()

@ -58,7 +58,7 @@ cdef int _get_metadata(void *state,
cdef void _destroy(void *state) except * with gil: cdef void _destroy(void *state) except * with gil:
cpython.Py_DECREF(<object>state) cpython.Py_DECREF(<object>state)
grpc_shutdown_blocking() grpc_shutdown()
cdef class MetadataPluginCallCredentials(CallCredentials): cdef class MetadataPluginCallCredentials(CallCredentials):
@ -124,7 +124,7 @@ cdef class SSLSessionCacheLRU:
def __dealloc__(self): def __dealloc__(self):
if self._cache != NULL: if self._cache != NULL:
grpc_ssl_session_cache_destroy(self._cache) grpc_ssl_session_cache_destroy(self._cache)
grpc_shutdown_blocking() grpc_shutdown()
cdef class SSLChannelCredentials(ChannelCredentials): cdef class SSLChannelCredentials(ChannelCredentials):
@ -190,7 +190,7 @@ cdef class ServerCertificateConfig:
def __dealloc__(self): def __dealloc__(self):
grpc_ssl_server_certificate_config_destroy(self.c_cert_config) grpc_ssl_server_certificate_config_destroy(self.c_cert_config)
gpr_free(self.c_ssl_pem_key_cert_pairs) gpr_free(self.c_ssl_pem_key_cert_pairs)
grpc_shutdown_blocking() grpc_shutdown()
cdef class ServerCredentials: cdef class ServerCredentials:
@ -206,7 +206,7 @@ cdef class ServerCredentials:
def __dealloc__(self): def __dealloc__(self):
if self.c_credentials != NULL: if self.c_credentials != NULL:
grpc_server_credentials_release(self.c_credentials) grpc_server_credentials_release(self.c_credentials)
grpc_shutdown_blocking() grpc_shutdown()
cdef const char* _get_c_pem_root_certs(pem_root_certs): cdef const char* _get_c_pem_root_certs(pem_root_certs):
if pem_root_certs is None: if pem_root_certs is None:

@ -334,6 +334,7 @@ cdef extern from "grpc/grpc.h":
grpc_op_data data grpc_op_data data
void grpc_init() nogil void grpc_init() nogil
void grpc_shutdown() nogil
void grpc_shutdown_blocking() nogil void grpc_shutdown_blocking() nogil
int grpc_is_initialized() nogil int grpc_is_initialized() nogil

@ -39,7 +39,7 @@ cdef class SocketWrapper:
self.len = 0 self.len = 0
def __dealloc__(self): def __dealloc__(self):
grpc_shutdown_blocking() grpc_shutdown()
cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil: cdef grpc_error* socket_init(grpc_custom_socket* socket, int domain) with gil:
sw = SocketWrapper() sw = SocketWrapper()
@ -267,7 +267,7 @@ cdef class ResolveWrapper:
self.c_port = NULL self.c_port = NULL
def __dealloc__(self): def __dealloc__(self):
grpc_shutdown_blocking() grpc_shutdown()
cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper): cdef socket_resolve_async_cython(ResolveWrapper resolve_wrapper):
try: try:
@ -323,7 +323,7 @@ cdef class TimerWrapper:
self.timer.stop() self.timer.stop()
def __dealloc__(self): def __dealloc__(self):
grpc_shutdown_blocking() grpc_shutdown()
cdef void timer_start(grpc_custom_timer* t) with gil: cdef void timer_start(grpc_custom_timer* t) with gil:
timer = TimerWrapper(t.timeout_ms / 1000.0) timer = TimerWrapper(t.timeout_ms / 1000.0)

@ -137,7 +137,7 @@ cdef class CallDetails:
def __dealloc__(self): def __dealloc__(self):
with nogil: with nogil:
grpc_call_details_destroy(&self.c_details) grpc_call_details_destroy(&self.c_details)
grpc_shutdown_blocking() grpc_shutdown()
@property @property
def method(self): def method(self):

@ -154,4 +154,4 @@ cdef class Server:
def __dealloc__(self): def __dealloc__(self):
if self.c_server == NULL: if self.c_server == NULL:
grpc_shutdown_blocking() grpc_shutdown()

Loading…
Cancel
Save