|
|
|
@ -26,7 +26,7 @@ from grpc._cython import cygrpc |
|
|
|
|
|
|
|
|
|
from . import _base_call |
|
|
|
|
from ._metadata import Metadata |
|
|
|
|
from ._typing import (DeserializingFunction, DoneCallbackType, MetadataType, |
|
|
|
|
from ._typing import (DeserializingFunction, DoneCallbackType, |
|
|
|
|
MetadatumType, RequestIterableType, RequestType, |
|
|
|
|
ResponseType, SerializingFunction) |
|
|
|
|
|
|
|
|
@ -61,15 +61,15 @@ class AioRpcError(grpc.RpcError): |
|
|
|
|
|
|
|
|
|
_code: grpc.StatusCode |
|
|
|
|
_details: Optional[str] |
|
|
|
|
_initial_metadata: Optional[MetadataType] |
|
|
|
|
_trailing_metadata: Optional[MetadataType] |
|
|
|
|
_initial_metadata: Optional[Metadata] |
|
|
|
|
_trailing_metadata: Optional[Metadata] |
|
|
|
|
_debug_error_string: Optional[str] |
|
|
|
|
|
|
|
|
|
def __init__(self, |
|
|
|
|
code: grpc.StatusCode, |
|
|
|
|
details: Optional[str] = None, |
|
|
|
|
initial_metadata: Optional[MetadataType] = None, |
|
|
|
|
trailing_metadata: Optional[MetadataType] = None, |
|
|
|
|
initial_metadata: Optional[Metadata] = None, |
|
|
|
|
trailing_metadata: Optional[Metadata] = None, |
|
|
|
|
debug_error_string: Optional[str] = None) -> None: |
|
|
|
|
"""Constructor. |
|
|
|
|
|
|
|
|
@ -84,8 +84,8 @@ class AioRpcError(grpc.RpcError): |
|
|
|
|
super().__init__(self) |
|
|
|
|
self._code = code |
|
|
|
|
self._details = details |
|
|
|
|
self._initial_metadata = Metadata(*(initial_metadata or ())) |
|
|
|
|
self._trailing_metadata = Metadata(*(trailing_metadata or ())) |
|
|
|
|
self._initial_metadata = initial_metadata |
|
|
|
|
self._trailing_metadata = trailing_metadata |
|
|
|
|
self._debug_error_string = debug_error_string |
|
|
|
|
|
|
|
|
|
def code(self) -> grpc.StatusCode: |
|
|
|
@ -104,7 +104,7 @@ class AioRpcError(grpc.RpcError): |
|
|
|
|
""" |
|
|
|
|
return self._details |
|
|
|
|
|
|
|
|
|
def initial_metadata(self) -> Optional[MetadataType]: |
|
|
|
|
def initial_metadata(self) -> Metadata: |
|
|
|
|
"""Accesses the initial metadata sent by the server. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
@ -112,7 +112,7 @@ class AioRpcError(grpc.RpcError): |
|
|
|
|
""" |
|
|
|
|
return self._initial_metadata |
|
|
|
|
|
|
|
|
|
def trailing_metadata(self) -> Optional[MetadataType]: |
|
|
|
|
def trailing_metadata(self) -> Metadata: |
|
|
|
|
"""Accesses the trailing metadata sent by the server. |
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
@ -141,13 +141,13 @@ class AioRpcError(grpc.RpcError): |
|
|
|
|
return self._repr() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _create_rpc_error(initial_metadata: Optional[MetadataType], |
|
|
|
|
def _create_rpc_error(initial_metadata: Metadata, |
|
|
|
|
status: cygrpc.AioRpcStatus) -> AioRpcError: |
|
|
|
|
return AioRpcError( |
|
|
|
|
_common.CYGRPC_STATUS_CODE_TO_STATUS_CODE[status.code()], |
|
|
|
|
status.details(), |
|
|
|
|
initial_metadata, |
|
|
|
|
status.trailing_metadata(), |
|
|
|
|
Metadata.from_tuple(initial_metadata), |
|
|
|
|
Metadata.from_tuple(status.trailing_metadata()), |
|
|
|
|
status.debug_error_string(), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -164,7 +164,7 @@ class Call: |
|
|
|
|
_request_serializer: SerializingFunction |
|
|
|
|
_response_deserializer: DeserializingFunction |
|
|
|
|
|
|
|
|
|
def __init__(self, cython_call: cygrpc._AioCall, metadata: MetadataType, |
|
|
|
|
def __init__(self, cython_call: cygrpc._AioCall, metadata: Metadata, |
|
|
|
|
request_serializer: SerializingFunction, |
|
|
|
|
response_deserializer: DeserializingFunction, |
|
|
|
|
loop: asyncio.AbstractEventLoop) -> None: |
|
|
|
@ -204,14 +204,14 @@ class Call: |
|
|
|
|
def time_remaining(self) -> Optional[float]: |
|
|
|
|
return self._cython_call.time_remaining() |
|
|
|
|
|
|
|
|
|
async def initial_metadata(self) -> MetadataType: |
|
|
|
|
async def initial_metadata(self) -> Metadata: |
|
|
|
|
raw_metadata_tuple = await self._cython_call.initial_metadata() |
|
|
|
|
return Metadata(*(raw_metadata_tuple or ())) |
|
|
|
|
return Metadata.from_tuple(raw_metadata_tuple) |
|
|
|
|
|
|
|
|
|
async def trailing_metadata(self) -> MetadataType: |
|
|
|
|
async def trailing_metadata(self) -> Metadata: |
|
|
|
|
raw_metadata_tuple = (await |
|
|
|
|
self._cython_call.status()).trailing_metadata() |
|
|
|
|
return Metadata(*(raw_metadata_tuple or ())) |
|
|
|
|
return Metadata.from_tuple(raw_metadata_tuple) |
|
|
|
|
|
|
|
|
|
async def code(self) -> grpc.StatusCode: |
|
|
|
|
cygrpc_code = (await self._cython_call.status()).code() |
|
|
|
@ -474,7 +474,7 @@ class UnaryUnaryCall(_UnaryResponseMixin, Call, _base_call.UnaryUnaryCall): |
|
|
|
|
|
|
|
|
|
# pylint: disable=too-many-arguments |
|
|
|
|
def __init__(self, request: RequestType, deadline: Optional[float], |
|
|
|
|
metadata: MetadataType, |
|
|
|
|
metadata: Metadata, |
|
|
|
|
credentials: Optional[grpc.CallCredentials], |
|
|
|
|
wait_for_ready: Optional[bool], channel: cygrpc.AioChannel, |
|
|
|
|
method: bytes, request_serializer: SerializingFunction, |
|
|
|
@ -523,7 +523,7 @@ class UnaryStreamCall(_StreamResponseMixin, Call, _base_call.UnaryStreamCall): |
|
|
|
|
|
|
|
|
|
# pylint: disable=too-many-arguments |
|
|
|
|
def __init__(self, request: RequestType, deadline: Optional[float], |
|
|
|
|
metadata: MetadataType, |
|
|
|
|
metadata: Metadata, |
|
|
|
|
credentials: Optional[grpc.CallCredentials], |
|
|
|
|
wait_for_ready: Optional[bool], channel: cygrpc.AioChannel, |
|
|
|
|
method: bytes, request_serializer: SerializingFunction, |
|
|
|
@ -563,7 +563,7 @@ class StreamUnaryCall(_StreamRequestMixin, _UnaryResponseMixin, Call, |
|
|
|
|
|
|
|
|
|
# pylint: disable=too-many-arguments |
|
|
|
|
def __init__(self, request_iterator: Optional[RequestIterableType], |
|
|
|
|
deadline: Optional[float], metadata: MetadataType, |
|
|
|
|
deadline: Optional[float], metadata: Metadata, |
|
|
|
|
credentials: Optional[grpc.CallCredentials], |
|
|
|
|
wait_for_ready: Optional[bool], channel: cygrpc.AioChannel, |
|
|
|
|
method: bytes, request_serializer: SerializingFunction, |
|
|
|
@ -601,7 +601,7 @@ class StreamStreamCall(_StreamRequestMixin, _StreamResponseMixin, Call, |
|
|
|
|
|
|
|
|
|
# pylint: disable=too-many-arguments |
|
|
|
|
def __init__(self, request_iterator: Optional[RequestIterableType], |
|
|
|
|
deadline: Optional[float], metadata: MetadataType, |
|
|
|
|
deadline: Optional[float], metadata: Metadata, |
|
|
|
|
credentials: Optional[grpc.CallCredentials], |
|
|
|
|
wait_for_ready: Optional[bool], channel: cygrpc.AioChannel, |
|
|
|
|
method: bytes, request_serializer: SerializingFunction, |
|
|
|
|