Renamed the callback_start_batch to execute_batch

pull/21232/head
Lidi Zheng 5 years ago
parent eff9f936b9
commit 160900c897
  1. 6
      src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi
  2. 18
      src/python/grpcio/grpc/_cython/_cygrpc/aio/callback_common.pyx.pxi
  3. 6
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi

@ -146,7 +146,7 @@ cdef class _AioCall:
receive_status_on_client_op)
try:
await async_start_batch(self._grpc_call_wrapper,
await execute_batch(self._grpc_call_wrapper,
ops,
self._loop)
except asyncio.CancelledError:
@ -178,7 +178,7 @@ cdef class _AioCall:
"""Handles the status sent by peer once received."""
cdef ReceiveStatusOnClientOperation op = ReceiveStatusOnClientOperation(_EMPTY_FLAGS)
cdef tuple ops = (op,)
await async_start_batch(self._grpc_call_wrapper, ops, self._loop)
await execute_batch(self._grpc_call_wrapper, ops, self._loop)
cdef AioRpcStatus status = AioRpcStatus(
op.code(),
op.details(),
@ -249,7 +249,7 @@ cdef class _AioCall:
)
# Actually sends out the request message.
await async_start_batch(self._grpc_call_wrapper,
await execute_batch(self._grpc_call_wrapper,
outbound_ops,
self._loop)

@ -85,10 +85,10 @@ cdef class CallbackCompletionQueue:
grpc_completion_queue_destroy(self._cq)
class CallbackStartBatchError(Exception): pass
class ExecuteBatchError(Exception): pass
async def async_start_batch(GrpcCallWrapper grpc_call_wrapper,
async def execute_batch(GrpcCallWrapper grpc_call_wrapper,
tuple operations,
object loop):
"""The callback version of start batch operations."""
@ -98,7 +98,7 @@ async def async_start_batch(GrpcCallWrapper grpc_call_wrapper,
cdef object future = loop.create_future()
cdef CallbackWrapper wrapper = CallbackWrapper(
future,
CallbackFailureHandler('async_start_batch', operations, CallbackStartBatchError))
CallbackFailureHandler('execute_batch', operations, ExecuteBatchError))
# NOTE(lidiz) Without Py_INCREF, the wrapper object will be destructed
# when calling "await". This is an over-optimization by Cython.
cpython.Py_INCREF(wrapper)
@ -109,7 +109,7 @@ async def async_start_batch(GrpcCallWrapper grpc_call_wrapper,
wrapper.c_functor(), NULL)
if error != GRPC_CALL_OK:
raise CallbackStartBatchError("Failed grpc_call_start_batch: {}".format(error))
raise ExecuteBatchError("Failed grpc_call_start_batch: {}".format(error))
await future
cpython.Py_DECREF(wrapper)
@ -129,8 +129,8 @@ async def _receive_message(GrpcCallWrapper grpc_call_wrapper,
cdef ReceiveMessageOperation receive_op = ReceiveMessageOperation(_EMPTY_FLAG)
cdef tuple ops = (receive_op,)
try:
await async_start_batch(grpc_call_wrapper, ops, loop)
except CallbackStartBatchError as e:
await execute_batch(grpc_call_wrapper, ops, loop)
except ExecuteBatchError as e:
# NOTE(lidiz) The receive message operation has two ways to indicate
# finish state : 1) returns empty message due to EOF; 2) fails inside
# the callback (e.g. cancelled).
@ -154,7 +154,7 @@ async def _send_message(GrpcCallWrapper grpc_call_wrapper,
SendInitialMetadataOperation(None, _EMPTY_FLAG),
op,
)
await async_start_batch(grpc_call_wrapper, ops, loop)
await execute_batch(grpc_call_wrapper, ops, loop)
async def _send_initial_metadata(GrpcCallWrapper grpc_call_wrapper,
@ -164,12 +164,12 @@ async def _send_initial_metadata(GrpcCallWrapper grpc_call_wrapper,
metadata,
_EMPTY_FLAG)
cdef tuple ops = (op,)
await async_start_batch(grpc_call_wrapper, ops, loop)
await execute_batch(grpc_call_wrapper, ops, loop)
async def _receive_initial_metadata(GrpcCallWrapper grpc_call_wrapper,
object loop):
cdef ReceiveInitialMetadataOperation op = ReceiveInitialMetadataOperation(_EMPTY_FLAGS)
cdef tuple ops = (op,)
await async_start_batch(grpc_call_wrapper, ops, loop)
await execute_batch(grpc_call_wrapper, ops, loop)
return op.initial_metadata()

@ -135,7 +135,7 @@ async def _handle_unary_unary_rpc(object method_handler,
SendInitialMetadataOperation(None, _EMPTY_FLAGS),
SendMessageOperation(response_raw, _EMPTY_FLAGS),
)
await async_start_batch(rpc_state, send_ops, loop)
await execute_batch(rpc_state, send_ops, loop)
async def _handle_unary_stream_rpc(object method_handler,
@ -185,7 +185,7 @@ async def _handle_unary_stream_rpc(object method_handler,
)
cdef tuple ops = (op,)
await async_start_batch(rpc_state, ops, loop)
await execute_batch(rpc_state, ops, loop)
async def _handle_cancellation_from_core(object rpc_task,
@ -193,7 +193,7 @@ async def _handle_cancellation_from_core(object rpc_task,
object loop):
cdef ReceiveCloseOnServerOperation op = ReceiveCloseOnServerOperation(_EMPTY_FLAG)
cdef tuple ops = (op,)
await async_start_batch(rpc_state, ops, loop)
await execute_batch(rpc_state, ops, loop)
if op.cancelled() and not rpc_task.done():
rpc_task.cancel()

Loading…
Cancel
Save