diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi index c21a0d0eed1..7ae3ce9f080 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi @@ -157,10 +157,9 @@ cdef class _ServicerContext: return self._rpc_state.invocation_metadata() -cdef _find_method_handler(str method, list generic_handlers): - # TODO(lidiz) connects Metadata to call details +cdef _find_method_handler(str method, tuple metadata, list generic_handlers): cdef _HandlerCallDetails handler_call_details = _HandlerCallDetails(method, - None) + metadata) for generic_handler in generic_handlers: method_handler = generic_handler.service(handler_call_details) @@ -459,6 +458,7 @@ async def _handle_rpc(list generic_handlers, RPCState rpc_state, object loop): # Finds the method handler (application logic) method_handler = _find_method_handler( rpc_state.method().decode(), + rpc_state.invocation_metadata(), generic_handlers, ) if method_handler is None: diff --git a/src/python/grpcio/grpc/experimental/aio/_interceptor.py b/src/python/grpcio/grpc/experimental/aio/_interceptor.py index 7b4e2a0be87..8eddd8573a7 100644 --- a/src/python/grpcio/grpc/experimental/aio/_interceptor.py +++ b/src/python/grpcio/grpc/experimental/aio/_interceptor.py @@ -106,14 +106,14 @@ class InterceptedUnaryUnaryCall(_base_call.UnaryUnaryCall): def __init__( # pylint: disable=R0913 self, interceptors: Sequence[UnaryUnaryClientInterceptor], request: RequestType, timeout: Optional[float], - credentials: Optional[grpc.CallCredentials], + metadata: Optional[MetadataType], credentials: Optional[grpc.CallCredentials], channel: cygrpc.AioChannel, method: bytes, request_serializer: SerializingFunction, response_deserializer: DeserializingFunction) -> None: self._channel = channel self._loop = asyncio.get_event_loop() self._interceptors_task = asyncio.ensure_future( - self._invoke(interceptors, method, timeout, credentials, request, + self._invoke(interceptors, method, timeout, metadata, credentials, request, request_serializer, response_deserializer)) def __del__(self): @@ -122,6 +122,7 @@ class InterceptedUnaryUnaryCall(_base_call.UnaryUnaryCall): async def _invoke( # pylint: disable=R0913 self, interceptors: Sequence[UnaryUnaryClientInterceptor], method: bytes, timeout: Optional[float], + metadata: Optional[MetadataType], credentials: Optional[grpc.CallCredentials], request: RequestType, request_serializer: SerializingFunction, response_deserializer: DeserializingFunction) -> UnaryUnaryCall: @@ -148,7 +149,7 @@ class InterceptedUnaryUnaryCall(_base_call.UnaryUnaryCall): else: return UnaryUnaryCall( request, _timeout_to_deadline(client_call_details.timeout), - client_call_details.credentials, self._channel, + metadata, client_call_details.credentials, self._channel, client_call_details.method, request_serializer, response_deserializer)