Merge pull request #23945 from lidizheng/aio-ref-count-fix

[Aio] Prevent call objects from outliving its parent channel or server
pull/23959/head
Lidi Zheng 4 years ago committed by GitHub
commit fa3a261844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi
  2. 2
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi

@ -46,6 +46,7 @@ cdef class _AioCall(GrpcCallWrapper):
def __cinit__(self, AioChannel channel, object deadline,
bytes method, CallCredentials call_credentials, object wait_for_ready):
init_grpc_aio()
self.call = NULL
self._channel = channel
self._loop = channel.loop
@ -63,6 +64,7 @@ cdef class _AioCall(GrpcCallWrapper):
def __dealloc__(self):
if self.call:
grpc_call_unref(self.call)
shutdown_grpc_aio()
def _repr(self) -> str:
"""Assembles the RPC representation string."""

@ -45,6 +45,7 @@ class _ServerStoppedError(BaseError):
cdef class RPCState:
def __cinit__(self, AioServer server):
init_grpc_aio()
self.call = NULL
self.server = server
grpc_metadata_array_init(&self.request_metadata)
@ -106,6 +107,7 @@ cdef class RPCState:
grpc_metadata_array_destroy(&self.request_metadata)
if self.call:
grpc_call_unref(self.call)
shutdown_grpc_aio()
cdef class _ServicerContext:

Loading…
Cancel
Save