diff --git a/src/python/grpcio/grpc/_simple_stubs.py b/src/python/grpcio/grpc/_simple_stubs.py index ae30be1bacb..3edf72c3422 100644 --- a/src/python/grpcio/grpc/_simple_stubs.py +++ b/src/python/grpcio/grpc/_simple_stubs.py @@ -228,6 +228,7 @@ def unary_unary( Returns: The response to the RPC. """ + grpc.experimental.warn_experimental("unary_unary") channel = ChannelCache.get().get_channel(target, options, channel_credentials, compression) multicallable = channel.unary_unary(method, request_serializer, @@ -298,6 +299,7 @@ def unary_stream( Returns: An iterator of responses. """ + grpc.experimental.warn_experimental("unary_stream") channel = ChannelCache.get().get_channel(target, options, channel_credentials, compression) multicallable = channel.unary_stream(method, request_serializer, @@ -368,6 +370,7 @@ def stream_unary( Returns: The response to the RPC. """ + grpc.experimental.warn_experimental("stream_unary") channel = ChannelCache.get().get_channel(target, options, channel_credentials, compression) multicallable = channel.stream_unary(method, request_serializer, @@ -438,6 +441,7 @@ def stream_stream( Returns: An iterator of responses. """ + grpc.experimental.warn_experimental("stream_stream") channel = ChannelCache.get().get_channel(target, options, channel_credentials, compression) multicallable = channel.stream_stream(method, request_serializer, diff --git a/src/python/grpcio/grpc/experimental/__init__.py b/src/python/grpcio/grpc/experimental/__init__.py index 9ab972daece..29f499f57c6 100644 --- a/src/python/grpcio/grpc/experimental/__init__.py +++ b/src/python/grpcio/grpc/experimental/__init__.py @@ -17,6 +17,7 @@ These APIs are subject to be removed during any minor version release. """ import sys +import warnings import grpc @@ -51,8 +52,19 @@ def insecure_channel_credentials(): return grpc.ChannelCredentials(_insecure_channel_credentials) +class ExperimentalApiWarning(Warning): + """A warning that an API is experimental.""" + + +def warn_experimental(api_name): + msg = ("{} is an experimental API. It is subject to change or ".format( + api_name) + "removal between minor releases. Proceed with caution.") + warnings.warn(msg, ExperimentalApiWarning, stacklevel=2) + + __all__ = ( 'ChannelOptions', + 'ExperimentalApiWarning', 'UsageError', 'insecure_channel_credentials', )