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(
name = "aio",
srcs = [
"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",
],
srcs = glob(["aio/**/*.py"]),
deps = [
"//src/python/grpcio/grpc/_cython:cygrpc",
],

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

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

Loading…
Cancel
Save