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.
pull/14639/head
Mehrdad Afshari 7 years ago
parent a33b807507
commit 56142a5dbf
  1. 23
      src/python/grpcio/grpc/_interceptor.py

@ -194,7 +194,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
self._interceptor = interceptor self._interceptor = interceptor
def __call__(self, request, timeout=None, metadata=None, credentials=None): def __call__(self, request, timeout=None, metadata=None, credentials=None):
response, ignored_call = self.with_call( response, ignored_call = self._with_call(
request, request,
timeout=timeout, timeout=timeout,
metadata=metadata, metadata=metadata,
@ -202,6 +202,14 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
return response return response
def with_call(self, request, timeout=None, metadata=None, credentials=None): 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, client_call_details = _ClientCallDetails(self._method, timeout,
metadata, credentials) metadata, credentials)
@ -283,7 +291,7 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
timeout=None, timeout=None,
metadata=None, metadata=None,
credentials=None): credentials=None):
response, ignored_call = self.with_call( response, ignored_call = self._with_call(
request_iterator, request_iterator,
timeout=timeout, timeout=timeout,
metadata=metadata, metadata=metadata,
@ -295,6 +303,17 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
timeout=None, timeout=None,
metadata=None, metadata=None,
credentials=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, client_call_details = _ClientCallDetails(self._method, timeout,
metadata, credentials) metadata, credentials)

Loading…
Cancel
Save