diff options
author | 2018-06-14 13:17:00 -0700 | |
---|---|---|
committer | 2018-06-14 13:17:00 -0700 | |
commit | 56142a5dbf5fea060781c7ad36b0410cc0d6ffa7 (patch) | |
tree | 06e0b95564ab4fbb057df10e719fb1ab58963f7b | |
parent | a33b8075076eb2a542212effa54d45c1d9c3b9ba (diff) |
Refactor: avoid calling with_call API
Avoid calling the public self.with_call
API internally and opt for sharing the
method body in a separate private method
and calling that instead.
-rw-r--r-- | src/python/grpcio/grpc/_interceptor.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/python/grpcio/grpc/_interceptor.py b/src/python/grpcio/grpc/_interceptor.py index 64203c9d27..30c98add10 100644 --- a/src/python/grpcio/grpc/_interceptor.py +++ b/src/python/grpcio/grpc/_interceptor.py @@ -194,7 +194,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): self._interceptor = interceptor def __call__(self, request, timeout=None, metadata=None, credentials=None): - response, ignored_call = self.with_call( + response, ignored_call = self._with_call( request, timeout=timeout, metadata=metadata, @@ -202,6 +202,14 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): return response def with_call(self, request, timeout=None, metadata=None, credentials=None): + return self._with_call( + request, + timeout=timeout, + metadata=metadata, + credentials=credentials) + + def _with_call(self, request, timeout=None, metadata=None, + credentials=None): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials) @@ -283,7 +291,7 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): timeout=None, metadata=None, credentials=None): - response, ignored_call = self.with_call( + response, ignored_call = self._with_call( request_iterator, timeout=timeout, metadata=metadata, @@ -295,6 +303,17 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): timeout=None, metadata=None, credentials=None): + return self._with_call( + request_iterator, + timeout=timeout, + metadata=metadata, + credentials=credentials) + + def _with_call(self, + request_iterator, + timeout=None, + metadata=None, + credentials=None): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials) |