python下使用pb,以及pb的压测

python下使用pb

下载安装

brew install protobuf , 其实如果有pip的话

pip install protobuf

pb的压测

ab -n 500 -c 20 -T application/x-protobuf -p ./pbdata_upload.txt  "http://xxx:8080/xxx?action=uploadfile&c=client"

其中pbdata_upload.txt,是经过pb序列化后生成的数据

遇到的问题:

  1. syntax = "proto2" syntax = "proto3"

  2. ImportError: No module named google.protobuf
    解决方案:pip install protobuf

  3. Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'o
    .protoc 指定syntax = "proto2" 解决。
    https://my.oschina.net/wangande2014/blog/672149

4.生成pb 命令

protoc -I=./  --python_out=./  FootprintDetailPageModel.proto
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容