本文整理匯總了Python中grpc.html方法的典型用法代碼示例。如果您正苦於以下問題:Python grpc.html方法的具體用法?Python grpc.html怎麽用?Python grpc.html使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類grpc
的用法示例。
在下文中一共展示了grpc.html方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _trace_result
# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import html [as 別名]
def _trace_result(self, guarded_span, rpc_info, result):
# If the RPC is called asynchronously, release the guard and add a callback
# so that the span can be finished once the future is done.
if isinstance(result, grpc.Future):
result.add_done_callback(
_make_future_done_callback(guarded_span.release(
), rpc_info, self._log_payloads, self._span_decorator))
return result
response = result
# Handle the case when the RPC is initiated via the with_call
# method and the result is a tuple with the first element as the
# response.
# http://www.grpc.io/grpc/python/grpc.html#grpc.UnaryUnaryMultiCallable.with_call
if isinstance(result, tuple):
response = result[0]
rpc_info.response = response
if self._log_payloads:
guarded_span.span.log_kv({'response': response})
if self._span_decorator is not None:
self._span_decorator(guarded_span.span, rpc_info)
return result
示例2: _trace_result
# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import html [as 別名]
def _trace_result(self, guarded_span, rpc_info, result):
# If the RPC is called asynchronously, release the guard and add a
# callback so that the span can be finished once the future is done.
if isinstance(result, grpc.Future):
result.add_done_callback(
_make_future_done_callback(guarded_span.release(), rpc_info)
)
return result
response = result
# Handle the case when the RPC is initiated via the with_call
# method and the result is a tuple with the first element as the
# response.
# http://www.grpc.io/grpc/python/grpc.html#grpc.UnaryUnaryMultiCallable.with_call
if isinstance(result, tuple):
response = result[0]
rpc_info.response = response
return result