'UserInfoResponse' object has no attribute 'total'","grpc_status":2}"

来源:23-7 启动grpc服务

慕哥139917

2021-08-21

在使用tests中的user.py时报错 status = StatusCode.UNKNOWN
details = “Exception calling application: ‘UserInfoResponse’ object has no attribute ‘total’“
debug_error_string = “{“created”:”@1629551948.113807000”,“description”:“Error received from peer ipv4:127.0.0.1:50051”,“file”:“src/core/lib/surface/call.cc”,“file_line”:1070,“grpc_message”:“Exception calling application: ‘UserInfoResponse’ object has no attribute ‘total’”,“grpc_status”:2}”

但是我找不到UserInfoResponse中的total属性,也没有设置这个属性。请问老师这是什么问题呢?

写回答

2回答

只是为了好玩

2021-11-19

应该是你写错了,哪里错了?

应该写

UserListResponse

你是不是写错成

UserInfoResponse

在test/user.py里,其中:

def user_list(self):
    print(f"{self.stub.GetUserList(user_pb2.PageInfo())}")
    rsp: user_pb2.UserListResponse = self.stub.GetUserList(user_pb2.PageInfo())
    print(rsp.total)

是这样的。

0
0

bobby

2021-08-23

你把完整的错误栈截图我看看呢

0
0

Go+Python打造电商系统 自研微服务框架 抓紧高薪机遇

快速转型Go工程师,成为具备双语言后端能力的开发者

510 学习 · 530 问题

查看课程