14 """gRPC's experimental APIs.
16 These APIs are subject to be removed during any minor version release.
27 _EXPERIMENTAL_APIS_USED =
set()
31 """Indicates a channel option unique to gRPC Python.
33 This enumeration is part of an EXPERIMENTAL API.
36 SingleThreadedUnaryStream: Perform unary-stream RPCs on a single thread.
38 SingleThreadedUnaryStream =
"SingleThreadedUnaryStream"
42 """Raised by the gRPC library to indicate usage not allowed by the API."""
48 _cygrpc.channel_credentials_insecure())
52 """Creates a ChannelCredentials for use with an insecure channel.
54 THIS IS AN EXPERIMENTAL API.
56 return _insecure_channel_credentials
60 """A warning that an API is experimental."""
64 if api_name
not in _EXPERIMENTAL_APIS_USED:
65 _EXPERIMENTAL_APIS_USED.add(api_name)
66 msg = (
"'{}' is an experimental API. It is subject to change or ".
68 "removal between minor releases. Proceed with caution.")
69 warnings.warn(msg, ExperimentalApiWarning, stacklevel=2 + stack_offset)
75 def _wrapper(*args, **kwargs):
77 return f(*args, **kwargs)
83 """Wraps the server method handler function.
85 The server implementation requires all server handlers being wrapped as
86 RpcMethodHandler objects. This helper function ease the pain of writing
87 server handler wrappers.
90 wrapper: A wrapper function that takes in a method handler behavior
91 (the actual function) and returns a wrapped function.
92 handler: A RpcMethodHandler object to be wrapped.
95 A newly created RpcMethodHandler.
100 if not handler.request_streaming:
101 if not handler.response_streaming:
104 return handler._replace(unary_unary=
wrapper(handler.unary_unary))
106 return handler._replace(unary_stream=
wrapper(handler.unary_stream))
108 if not handler.response_streaming:
109 return handler._replace(stream_unary=
wrapper(handler.stream_unary))
111 return handler._replace(
112 stream_stream=
wrapper(handler.stream_stream))
117 'ExperimentalApiWarning',
119 'insecure_channel_credentials',
120 'wrap_server_method_handler',
123 if sys.version_info > (3, 6):
128 __all__ = __all__ + (unary_unary, unary_stream, stream_unary, stream_stream)