基本 gRPC 版本无法运行

Pet*_*ris 3 python grpc

我试图实现一个简单的 gRPC 服务器/客户端,并将问题范围缩小到甚至基本的 gRPC Python 实现在我的机器上无法工作。

这是我尝试过的:

pip install grpcio grpcio-tools
git clone https://github.com/grpc/grpc.git
cd grpc/examples/python/route_guide
python run_codegen.py # Everything breaks whether I include this step or not
python route_guide_server.py
Run Code Online (Sandbox Code Playgroud)

并出现以下错误:

-------------- GetFeature --------------
Traceback (most recent call last):
  File "route_guide_client.py", line 119, in <module>
    run()
  File "route_guide_client.py", line 109, in run
    guide_get_feature(stub)
  File "route_guide_client.py", line 48, in guide_get_feature
    latitude=409146138, longitude=-746188906))
  File "route_guide_client.py", line 34, in guide_get_one_feature
    feature = stub.GetFeature(point)
  File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/grpc/_channel.py", line 514, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/grpc/_channel.py", line 448, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
    status = StatusCode.UNIMPLEMENTED
    details = "Method not found!"
    debug_error_string = "{"created":"@1530451116.454542000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1083,"grpc_message":"Method not found!","grpc_status":12}"
>
Run Code Online (Sandbox Code Playgroud)

有关我的机器配置的更多详细信息(如果有用)。

Pet*_*ris 8

发现端口50051被占用了!

  • 这以一种迂回的方式帮助了我。我遇到了“找不到方法!” 和“方法未实施!” 即使我盯着我刚刚编写的代码。结果我的服务器进程的 4 个副本仍在同一端口上运行。测试脚本在后台“&amp;”中生成了它们,但我忘记杀死它们。为什么这没有抛出“端口正在使用”?谁知道! (2认同)