【问题标题】:print full HTTP/2 gRPC response in Python在 Python 中打印完整的 HTTP/2 gRPC 响应
【发布时间】:2018-11-13 11:06:24
【问题描述】:

我有一个 Python 中的 gRPC 服务器,我正在寻找一种方法来打印它在收到请求后提供的完整 HTTP/2 响应。下面是接收请求并返回响应的方法。

@inject.params(storage='storage')
def getPerson(self, request,context=None, storage = None)
    logger.info('call of username {}'.format(
        request.username
    ))
    logger.info('Client Metadata {} '.format(
        context.invocation_metadata()
    ))

    response = mProto.Auth()
    response.value = 100
    logger.info('Client Metadata {} '.format(
        context.invocation_metadata()
    ))
    #some code
    response = storage.request(request.username, request.password)
    return response

【问题讨论】:

    标签: python http protocol-buffers grpc


    【解决方案1】:

    您可以通过定义 here 的环境变量在 gRPC 中启用调试日志记录。通过设置GRPC_VERBOSITY=DEBUGGRPC_TRACE=http,服务器将在其http2 堆栈中打印活动。您必须筛选输出以找到所需的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多