Skip to content

Commit

Permalink
Retain references to channel arguments
Browse files Browse the repository at this point in the history
This works around issue 15662 which is not as easy to implement as I
would prefer it to be.
  • Loading branch information
nathanielmanistaatgoogle committed Jun 6, 2018
1 parent ca7ba4d commit 9c86b20
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
cimport cpython


# TODO(https://github.com/grpc/grpc/issues/15662): Reform this.
cdef void* _copy_pointer(void* pointer):
return pointer


# TODO(https://github.com/grpc/grpc/issues/15662): Reform this.
cdef void _destroy_pointer(void* pointer):
pass

Expand Down
3 changes: 3 additions & 0 deletions src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ cdef class Channel:

cdef grpc_arg_pointer_vtable _vtable
cdef _ChannelState _state

# TODO(https://github.com/grpc/grpc/issues/15662): Eliminate this.
cdef tuple _arguments
2 changes: 2 additions & 0 deletions src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ cdef class Channel:
def __cinit__(
self, bytes target, object arguments,
ChannelCredentials channel_credentials):
arguments = () if arguments is None else tuple(arguments)
grpc_init()
self._state = _ChannelState()
self._vtable.copy = &_copy_pointer
Expand All @@ -410,6 +411,7 @@ cdef class Channel:
grpc_completion_queue_create_for_next(NULL))
self._state.c_connectivity_completion_queue = (
grpc_completion_queue_create_for_next(NULL))
self._arguments = arguments

def target(self):
cdef char *c_target
Expand Down
1 change: 1 addition & 0 deletions src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cdef class Server:
cdef bint is_shutdown # notification of complete shutdown received
# used at dealloc when user forgets to shutdown
cdef CompletionQueue backup_shutdown_queue
# TODO(https://github.com/grpc/grpc/issues/15662): Elide this.
cdef list references
cdef list registered_completion_queues

Expand Down

0 comments on commit 9c86b20

Please sign in to comment.