aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/grpc/_cython
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio/grpc/_cython')
-rw-r--r--src/python/grpcio/grpc/_cython/BUILD.bazel46
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi16
2 files changed, 58 insertions, 4 deletions
diff --git a/src/python/grpcio/grpc/_cython/BUILD.bazel b/src/python/grpcio/grpc/_cython/BUILD.bazel
new file mode 100644
index 0000000000..7124e83dee
--- /dev/null
+++ b/src/python/grpcio/grpc/_cython/BUILD.bazel
@@ -0,0 +1,46 @@
+package(default_visibility = ["//visibility:public"])
+
+load("//bazel:cython_library.bzl", "pyx_library")
+
+pyx_library(
+ name = "cygrpc",
+ srcs = [
+ "__init__.py",
+ "cygrpc.pxd",
+ "cygrpc.pyx",
+ "_cygrpc/grpc_string.pyx.pxi",
+ "_cygrpc/arguments.pyx.pxi",
+ "_cygrpc/call.pyx.pxi",
+ "_cygrpc/channel.pyx.pxi",
+ "_cygrpc/credentials.pyx.pxi",
+ "_cygrpc/completion_queue.pyx.pxi",
+ "_cygrpc/event.pyx.pxi",
+ "_cygrpc/metadata.pyx.pxi",
+ "_cygrpc/operation.pyx.pxi",
+ "_cygrpc/records.pyx.pxi",
+ "_cygrpc/security.pyx.pxi",
+ "_cygrpc/server.pyx.pxi",
+ "_cygrpc/tag.pyx.pxi",
+ "_cygrpc/time.pyx.pxi",
+ "_cygrpc/grpc_gevent.pyx.pxi",
+ "_cygrpc/grpc.pxi",
+ "_cygrpc/arguments.pxd.pxi",
+ "_cygrpc/call.pxd.pxi",
+ "_cygrpc/channel.pxd.pxi",
+ "_cygrpc/credentials.pxd.pxi",
+ "_cygrpc/completion_queue.pxd.pxi",
+ "_cygrpc/event.pxd.pxi",
+ "_cygrpc/metadata.pxd.pxi",
+ "_cygrpc/operation.pxd.pxi",
+ "_cygrpc/records.pxd.pxi",
+ "_cygrpc/security.pxd.pxi",
+ "_cygrpc/server.pxd.pxi",
+ "_cygrpc/tag.pxd.pxi",
+ "_cygrpc/time.pxd.pxi",
+ "_cygrpc/grpc_gevent.pxd.pxi",
+ ],
+ deps = [
+ "//:grpc",
+ ],
+)
+
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):