diff options
author | Nathaniel Manista <nathaniel@google.com> | 2016-06-13 20:14:18 +0000 |
---|---|---|
committer | Nathaniel Manista <nathaniel@google.com> | 2016-06-13 20:51:09 +0000 |
commit | 4547940d0671b528f2ace782466af94150cb7902 (patch) | |
tree | 4211ea8c20e5c6a03d1bf7545c2cb2709dde5b29 /src/python/grpcio/grpc/_utilities.py | |
parent | 55ca239bc2116857b347d8b1234e0cabf35640de (diff) |
Python GA code generation
Diffstat (limited to 'src/python/grpcio/grpc/_utilities.py')
-rw-r--r-- | src/python/grpcio/grpc/_utilities.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/python/grpcio/grpc/_utilities.py b/src/python/grpcio/grpc/_utilities.py index a4ca9b7282..4850967fbc 100644 --- a/src/python/grpcio/grpc/_utilities.py +++ b/src/python/grpcio/grpc/_utilities.py @@ -29,16 +29,41 @@ """Internal utilities for gRPC Python.""" +import collections import threading import time +import six + import grpc +from grpc import _common from grpc.framework.foundation import callable_util _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = ( 'Exception calling connectivity future "done" callback!') +class RpcMethodHandler( + collections.namedtuple( + '_RpcMethodHandler', + ('request_streaming', 'response_streaming', 'request_deserializer', + 'response_serializer', 'unary_unary', 'unary_stream', 'stream_unary', + 'stream_stream',)), + grpc.RpcMethodHandler): + pass + + +class DictionaryGenericHandler(grpc.GenericRpcHandler): + + def __init__(self, service, method_handlers): + self._method_handlers = { + _common.fully_qualified_method(service, method): method_handler + for method, method_handler in six.iteritems(method_handlers)} + + def service(self, handler_call_details): + return self._method_handlers.get(handler_call_details.method) + + class _ChannelReadyFuture(grpc.Future): def __init__(self, channel): @@ -144,4 +169,3 @@ def channel_ready_future(channel): ready_future = _ChannelReadyFuture(channel) ready_future.start() return ready_future - |