grpc message字段賦值錯誤

問題描述

今天在寫grpc客戶端時,對某個message字段賦值,結果報了這個錯誤node

164                 if args != "organization" and args != "user":
    165                     setattr(update_job, args, kwargs[args])
--> 166             patch_job.job = update_job
    167             request = msg_pb2.LukeRequest(method="PatchJob",user=kwargs["user"],
    168             organization=kwargs["organization"],patch_request=patch_job)

AttributeError: Assignment not allowed to field "job" in protocol message object.

問題分析

問題解答

參考code

patch_job.job.CopyFrom(update_job)

解決rpc

相關文章
相關標籤/搜索