@@ -37,27 +37,26 @@ cd grpc-codelabs/
37
37
### Python3
38
38
39
39
For this codelab, we require python 3.9 or higher, but recommend python 3.11. System-specific
40
- instructions can be found in Python documentation: [ Python Setup and Usage]
41
- (https://docs.python.org/3/using/index.html ).
40
+ instructions can be found in Python documentation: [ Python Setup and Usage] ( https://docs.python.org/3/using/index.html ) .
42
41
43
42
### Pip3
44
43
45
- We recommend using the latest pip, see [ Installation - pip]
46
- ( https://pip.pypa.io/en/stable/installation/ ). In some OS distributions, ` ensurepip ` is not
47
- available out-of-box. On Debian/Ubuntu, you may need to run.
44
+ We recommend using the latest pip, see [ Installation - pip] ( https://pip.pypa.io/en/stable/installation/ ) .
45
+ In some OS distributions, ` ensurepip ` is not available out-of-box. On Debian/Ubuntu, you may need
46
+ to run.
48
47
49
48
``` sh
50
49
sudo apt-get install python3-pip
51
50
```
52
51
53
- If necessary, upgrade your version of pip:
52
+ If necessary, upgrade your version of pip:
54
53
55
54
``` sh
56
55
python3 -m ensurepip --upgrade
57
56
```
58
57
59
58
If your python installation is owned by the system, pip will be installed in the user directory. If
60
- you may see a warning like this, ensure the pip directory is in PATH:
59
+ you may see a warning like this, ensure the pip directory is in ` $ PATH` :
61
60
62
61
```
63
62
WARNING: The scripts pip3 and pip3.9 are installed in '/Users/sergiitk/Library/Python/3.9/bin' which is not on PATH.
@@ -109,7 +108,7 @@ Our first step is to define the gRPC *service* and the method *request* and *res
109
108
110
109
Let’s start by defining the messages and service in ` route_guide.proto ` .
111
110
112
- ### Define proto messages
111
+ ### Define Proto Messages
113
112
114
113
Our ` .proto ` file contains protocol buffer message type definitions for all the request and response
115
114
types used in our service methods.
@@ -135,7 +134,7 @@ message Feature {
135
134
}
136
135
```
137
136
138
- ### Define RouteGuide service
137
+ ### Define RouteGuide Service
139
138
140
139
To define a service, you specify a named ` service ` in your ` .proto ` file:
141
140
@@ -160,7 +159,7 @@ rpc GetFeature(Point) returns (Feature) {}
160
159
161
160
> [ !TIP]
162
161
> For the complete .proto file, see
163
- > [ completed/protos/route_guide.proto] ( https://github.com/grpc-ecosystem/grpc-codelabs/blob/main/codelabs/grpc-python-getting-started/completed/protos/route_guide.proto )
162
+ > [ ` completed/protos/route_guide.proto ` ] ( https://github.com/grpc-ecosystem/grpc-codelabs/blob/main/codelabs/grpc-python-getting-started/completed/protos/route_guide.proto )
164
163
165
164
## Generating client and server code
166
165
@@ -172,8 +171,8 @@ First, install the grpcio-tools package:
172
171
pip install --require-virtualenv grpcio-tools
173
172
```
174
173
175
- If you see ` ERROR: Could not find an activated virtualenv (required) ` , please follow the section
176
- [ Activate virtual environment] ( #activate-virtual-environment ) , then cd into ` start_here ` .
174
+ If you see ` ERROR: Could not find an activated virtualenv (required) ` , please
175
+ [ activate virtual environment] ( #activate-virtual-environment ) , then cd into ` start_here ` .
177
176
178
177
Use the following command to generate the Python code:
179
178
@@ -253,7 +252,7 @@ so that clients can actually use your service:
253
252
def serve ():
254
253
server = grpc.server(futures.ThreadPoolExecutor(max_workers = 10 ))
255
254
route_guide_pb2_grpc.add_RouteGuideServicer_to_server(RouteGuideServicer(), server)
256
- listen_addr = " [::] :50051"
255
+ listen_addr = " localhost :50051"
257
256
server.add_insecure_port(listen_addr)
258
257
print (f " Starting server on { listen_addr} " )
259
258
server.start()
@@ -330,7 +329,7 @@ Run the server:
330
329
python route_guide_server.py
331
330
```
332
331
333
- From a different terminal, [ Activate virtual environment] ( #activate-virtual-environment ) , then run
332
+ From a different terminal, [ activate virtual environment] ( #activate-virtual-environment ) , then run
334
333
the client:
335
334
336
335
``` sh
0 commit comments