Make sanity tests happy

pull/21987/head
Lidi Zheng 5 years ago
parent 1945c1108f
commit 0c7bf6c434
  1. 11
      src/python/grpcio/grpc/experimental/BUILD.bazel
  2. 5
      src/python/grpcio/grpc/experimental/aio/_base_channel.py
  3. 17
      src/python/grpcio/grpc/experimental/aio/_base_server.py

@ -2,16 +2,7 @@ package(default_visibility = ["//visibility:public"])
py_library( py_library(
name = "aio", name = "aio",
srcs = [ srcs = glob(["aio/**/*.py"]),
"aio/__init__.py",
"aio/_base_call.py",
"aio/_call.py",
"aio/_channel.py",
"aio/_interceptor.py",
"aio/_server.py",
"aio/_typing.py",
"aio/_utils.py",
],
deps = [ deps = [
"//src/python/grpcio/grpc/_cython:cygrpc", "//src/python/grpcio/grpc/_cython:cygrpc",
], ],

@ -14,13 +14,12 @@
"""Abstract base classes for Channel objects and Multicallable objects.""" """Abstract base classes for Channel objects and Multicallable objects."""
import abc import abc
from typing import Any, AsyncIterable, Optional, Sequence from typing import Any, AsyncIterable, Optional
import grpc import grpc
from . import _base_call from . import _base_call
from ._typing import (ChannelArgumentType, DeserializingFunction, MetadataType, from ._typing import DeserializingFunction, MetadataType, SerializingFunction
SerializingFunction)
_IMMUTABLE_EMPTY_TUPLE = tuple() _IMMUTABLE_EMPTY_TUPLE = tuple()

@ -14,12 +14,11 @@
"""Abstract base classes for server-side classes.""" """Abstract base classes for server-side classes."""
import abc import abc
from concurrent.futures import Executor from typing import Generic, NoReturn, Optional, Sequence
from typing import Any, Optional, Sequence, NoReturn
import grpc import grpc
from ._typing import ChannelArgumentType, MetadataType, RequestType, ResponseType from ._typing import MetadataType, RequestType, ResponseType
class Server(abc.ABC): class Server(abc.ABC):
@ -125,9 +124,10 @@ class Server(abc.ABC):
""" """
class ServicerContext(abc.ABC): class ServicerContext(Generic[RequestType, ResponseType], abc.ABC):
"""A context object passed to method implementations.""" """A context object passed to method implementations."""
@abc.abstractmethod
async def read(self) -> RequestType: async def read(self) -> RequestType:
"""Reads one message from the RPC. """Reads one message from the RPC.
@ -141,6 +141,7 @@ class ServicerContext(abc.ABC):
An RpcError exception if the read failed. An RpcError exception if the read failed.
""" """
@abc.abstractmethod
async def write(self, message: ResponseType) -> None: async def write(self, message: ResponseType) -> None:
"""Writes one message to the RPC. """Writes one message to the RPC.
@ -151,6 +152,7 @@ class ServicerContext(abc.ABC):
An RpcError exception if the write failed. An RpcError exception if the write failed.
""" """
@abc.abstractmethod
async def send_initial_metadata(self, async def send_initial_metadata(self,
initial_metadata: MetadataType) -> None: initial_metadata: MetadataType) -> None:
"""Sends the initial metadata value to the client. """Sends the initial metadata value to the client.
@ -162,6 +164,7 @@ class ServicerContext(abc.ABC):
initial_metadata: The initial :term:`metadata`. initial_metadata: The initial :term:`metadata`.
""" """
@abc.abstractmethod
async def abort(self, code: grpc.StatusCode, details: str, async def abort(self, code: grpc.StatusCode, details: str,
trailing_metadata: MetadataType) -> NoReturn: trailing_metadata: MetadataType) -> NoReturn:
"""Raises an exception to terminate the RPC with a non-OK status. """Raises an exception to terminate the RPC with a non-OK status.
@ -182,6 +185,7 @@ class ServicerContext(abc.ABC):
RPC to the gRPC runtime. RPC to the gRPC runtime.
""" """
@abc.abstractmethod
async def set_trailing_metadata(self, async def set_trailing_metadata(self,
trailing_metadata: MetadataType) -> None: trailing_metadata: MetadataType) -> None:
"""Sends the trailing metadata for the RPC. """Sends the trailing metadata for the RPC.
@ -193,6 +197,7 @@ class ServicerContext(abc.ABC):
trailing_metadata: The trailing :term:`metadata`. trailing_metadata: The trailing :term:`metadata`.
""" """
@abc.abstractmethod
def invocation_metadata(self) -> Optional[MetadataType]: def invocation_metadata(self) -> Optional[MetadataType]:
"""Accesses the metadata from the sent by the client. """Accesses the metadata from the sent by the client.
@ -200,6 +205,7 @@ class ServicerContext(abc.ABC):
The invocation :term:`metadata`. The invocation :term:`metadata`.
""" """
@abc.abstractmethod
def set_code(self, code: grpc.StatusCode) -> None: def set_code(self, code: grpc.StatusCode) -> None:
"""Sets the value to be used as status code upon RPC completion. """Sets the value to be used as status code upon RPC completion.
@ -210,6 +216,7 @@ class ServicerContext(abc.ABC):
code: A StatusCode object to be sent to the client. code: A StatusCode object to be sent to the client.
""" """
@abc.abstractmethod
def set_details(self, details: str) -> None: def set_details(self, details: str) -> None:
"""Sets the value to be used as detail string upon RPC completion. """Sets the value to be used as detail string upon RPC completion.
@ -221,6 +228,7 @@ class ServicerContext(abc.ABC):
termination of the RPC. termination of the RPC.
""" """
@abc.abstractmethod
def set_compression(self, compression: grpc.Compression) -> None: def set_compression(self, compression: grpc.Compression) -> None:
"""Set the compression algorithm to be used for the entire call. """Set the compression algorithm to be used for the entire call.
@ -231,6 +239,7 @@ class ServicerContext(abc.ABC):
grpc.compression.Gzip. grpc.compression.Gzip.
""" """
@abc.abstractmethod
def disable_next_message_compression(self) -> None: def disable_next_message_compression(self) -> None:
"""Disables compression for the next response message. """Disables compression for the next response message.

Loading…
Cancel
Save