aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Eric Gribkoff <ericgribkoff@google.com>2018-08-10 13:35:24 -0700
committerGravatar GitHub <noreply@github.com>2018-08-10 13:35:24 -0700
commitea7c0a60c5d3a12f224412485a73a4f98b7a8723 (patch)
tree1116fbeb96513f8ca92c38ba54345e29b0ad551b /src
parentfa2961abd8db4220b8a60cf011e516953ebacd69 (diff)
parent5a664d7260c0de1f80ebe0813f322f237ff2b610 (diff)
Merge pull request #16296 from ericgribkoff/close_segfault_fix
Check if Python channel is closed before starting core ops
Diffstat (limited to 'src')
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
index 893df8eac6..aa187e88a6 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
@@ -309,13 +309,18 @@ cdef SegregatedCall _segregated_call(
_ChannelState state, int flags, method, host, object deadline,
object metadata, CallCredentials credentials, operationses_and_user_tags):
cdef _CallState call_state = _CallState()
- cdef grpc_completion_queue *c_completion_queue = (
- grpc_completion_queue_create_for_next(NULL))
cdef SegregatedCall segregated_call
+ cdef grpc_completion_queue *c_completion_queue
def on_success(started_tags):
state.segregated_call_states.add(call_state)
+ with state.condition:
+ if state.open:
+ c_completion_queue = (grpc_completion_queue_create_for_next(NULL))
+ else:
+ raise ValueError('Cannot invoke RPC on closed channel!')
+
try:
_call(
state, call_state, c_completion_queue, on_success, flags, method, host,
@@ -443,8 +448,11 @@ cdef class Channel:
def check_connectivity_state(self, bint try_to_connect):
with self._state.condition:
- return grpc_channel_check_connectivity_state(
- self._state.c_channel, try_to_connect)
+ if self._state.open:
+ return grpc_channel_check_connectivity_state(
+ self._state.c_channel, try_to_connect)
+ else:
+ raise ValueError('Cannot invoke RPC on closed channel!')
def watch_connectivity_state(
self, grpc_connectivity_state last_observed_state, object deadline):