@ -295,12 +295,14 @@ cdef class _AioCall(GrpcCallWrapper):
async def unary_unary ( self ,
async def unary_unary ( self ,
bytes request ,
bytes request ,
tuple outbound_initial_metadata ) :
tuple outbound_initial_metadata ,
object context = None ) :
""" Performs a unary unary RPC.
""" Performs a unary unary RPC.
Args :
Args :
request : the serialized requests in bytes .
request : the serialized requests in bytes .
outbound_initial_metadata : optional outbound metadata .
outbound_initial_metadata : optional outbound metadata .
context : instrumentation context .
"""
"""
cdef tuple ops
cdef tuple ops
@ -313,6 +315,8 @@ cdef class _AioCall(GrpcCallWrapper):
cdef ReceiveMessageOperation receive_message_op = ReceiveMessageOperation ( _EMPTY_FLAGS )
cdef ReceiveMessageOperation receive_message_op = ReceiveMessageOperation ( _EMPTY_FLAGS )
cdef ReceiveStatusOnClientOperation receive_status_on_client_op = ReceiveStatusOnClientOperation ( _EMPTY_FLAGS )
cdef ReceiveStatusOnClientOperation receive_status_on_client_op = ReceiveStatusOnClientOperation ( _EMPTY_FLAGS )
if context is not None :
set_instrumentation_context_on_call_aio ( self , context )
ops = ( initial_metadata_op , send_message_op , send_close_op ,
ops = ( initial_metadata_op , send_message_op , send_close_op ,
receive_initial_metadata_op , receive_message_op ,
receive_initial_metadata_op , receive_message_op ,
receive_status_on_client_op )
receive_status_on_client_op )
@ -390,7 +394,8 @@ cdef class _AioCall(GrpcCallWrapper):
async def initiate_unary_stream ( self ,
async def initiate_unary_stream ( self ,
bytes request ,
bytes request ,
tuple outbound_initial_metadata ) :
tuple outbound_initial_metadata ,
object context = None ) :
"""Implementation of the start of a unary-stream call."""
"""Implementation of the start of a unary-stream call."""
# Peer may prematurely end this RPC at any point. We need a corutine
# Peer may prematurely end this RPC at any point. We need a corutine
# that watches if the server sends the final status.
# that watches if the server sends the final status.
@ -406,6 +411,8 @@ cdef class _AioCall(GrpcCallWrapper):
cdef Operation send_close_op = SendCloseFromClientOperation (
cdef Operation send_close_op = SendCloseFromClientOperation (
_EMPTY_FLAGS )
_EMPTY_FLAGS )
if context is not None :
set_instrumentation_context_on_call_aio ( self , context )
outbound_ops = (
outbound_ops = (
initial_metadata_op ,
initial_metadata_op ,
send_message_op ,
send_message_op ,
@ -429,7 +436,8 @@ cdef class _AioCall(GrpcCallWrapper):
async def stream_unary ( self ,
async def stream_unary ( self ,
tuple outbound_initial_metadata ,
tuple outbound_initial_metadata ,
object metadata_sent_observer ) :
object metadata_sent_observer ,
object context = None ) :
""" Actual implementation of the complete unary-stream call.
""" Actual implementation of the complete unary-stream call.
Needs to pay extra attention to the raise mechanism . If we want to
Needs to pay extra attention to the raise mechanism . If we want to
@ -460,6 +468,9 @@ cdef class _AioCall(GrpcCallWrapper):
cdef tuple inbound_ops
cdef tuple inbound_ops
cdef ReceiveMessageOperation receive_message_op = ReceiveMessageOperation ( _EMPTY_FLAGS )
cdef ReceiveMessageOperation receive_message_op = ReceiveMessageOperation ( _EMPTY_FLAGS )
cdef ReceiveStatusOnClientOperation receive_status_on_client_op = ReceiveStatusOnClientOperation ( _EMPTY_FLAGS )
cdef ReceiveStatusOnClientOperation receive_status_on_client_op = ReceiveStatusOnClientOperation ( _EMPTY_FLAGS )
if context is not None :
set_instrumentation_context_on_call_aio ( self , context )
inbound_ops = ( receive_message_op , receive_status_on_client_op )
inbound_ops = ( receive_message_op , receive_status_on_client_op )
# Executes all operations in one batch.
# Executes all operations in one batch.
@ -484,7 +495,8 @@ cdef class _AioCall(GrpcCallWrapper):
async def initiate_stream_stream ( self ,
async def initiate_stream_stream ( self ,
tuple outbound_initial_metadata ,
tuple outbound_initial_metadata ,
object metadata_sent_observer ) :
object metadata_sent_observer ,
object context = None ) :
""" Actual implementation of the complete stream-stream call.
""" Actual implementation of the complete stream-stream call.
Needs to pay extra attention to the raise mechanism . If we want to
Needs to pay extra attention to the raise mechanism . If we want to
@ -495,6 +507,9 @@ cdef class _AioCall(GrpcCallWrapper):
# that watches if the server sends the final status.
# that watches if the server sends the final status.
status_task = self . _loop . create_task ( self . _handle_status_once_received ( ) )
status_task = self . _loop . create_task ( self . _handle_status_once_received ( ) )
if context is not None :
set_instrumentation_context_on_call_aio ( self , context )
try :
try :
# Sends out initial_metadata ASAP.
# Sends out initial_metadata ASAP.
await _send_initial_metadata ( self ,
await _send_initial_metadata ( self ,