________________________________
发件人: harden
发送时间: 2022年8月1日 21:35
收件人: grpc-io+unsubscr...@googlegroups.com <grpc-io+unsubscr...@googlegroups.com>
主题: grpc protos_and_services load proto files error

Hi there!
I'm actually facing some issues and am wondering if I'm on a completely wrong 
track here. We're currently trying to make a common mock server used by python 
+ grpc +proto with experimental no-codegen API:
```
grpc.protos_and_services(protobuf_path)
```

However, we're currently facing the issues that load some proto files which we 
addressed like this:
```

for root, dirs, files in os.walk(path):
    for file in files:
        if '.proto' in file:
            try:
                _proto, _services = grpc.protos_and_services(file)
            except Exception as e:
                logger.error("Error: grpc.protos_and_services error {}, proto 
file {}".format(e, file))
                raise e
            service_list = inspect.getmembers(_services, inspect.isfunction)
            for (module_name, module_instance) in inspect.getmembers(_services, 
inspect.isclass):
                if 'Servicer' in module_name:
                    service_dict[module_name.split("Servicer")[0]] = (
                        _services, module_instance, [x[1] for x in service_list 
if module_name in x[0]][0],
                        _proto)

return service_dict

```

the error msg:
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "clarity.proto":
  live.xanchor.v1.Virtual: "live.xanchor.v1.Virtual" is already defined in file 
"virtual.proto".
  live.xanchor.v1.Virtual: Note that enum values use C++ scoping rules, meaning 
that enum values are siblings of their type, not children of it.  Therefore, 
"Virtual" must be unique within "live.xanchor.v1", not just within 
"ClarityLiveMode".

the clarity.proto like this:

enum ClarityLiveMode {
    ...
    Virtual = 5;
}

the virtual.proto like this:

service Virtual {
    rpc ...

}

How can I load proto files, and avoid this issue? thanks.





本邮件仅为指定收件人使用并可能包含保密信息,若您误收到本邮件,敬请通知发件人,并立即删除本邮件及所有副本。您不得擅自传播、转发、保存或复制此邮件(含附件)。感谢您的理解与配合。
This message may contain confidential information, and is intended only for the 
use of the addressee(s) named above. If you have received this message in 
error, please contact the sender immediately and delete all copies from your 
system. You are hereby notified that any dissemination, distribution, 
preservation or copying of this message and/or attachments is strictly 
prohibited. Thank you for your understanding and cooperation.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/SHXPR01MB05111E32CDCF3065E84EC12AAA9A9%40SHXPR01MB0511.CHNPR01.prod.partner.outlook.cn.

Reply via email to