aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/python/helloworld
diff options
context:
space:
mode:
authorGravatar Nathaniel Manista <nathaniel@google.com>2015-09-08 21:34:33 +0000
committerGravatar Nathaniel Manista <nathaniel@google.com>2015-09-10 16:09:17 +0000
commit061d288f559f786c1541f56192303314a61e5489 (patch)
tree3ddf30b2aef7cc3111176d4986c410ccad8c21e1 /examples/python/helloworld
parentf65d3c11023cd39b73c8832947889f656f2427a3 (diff)
Beta Python documentation correction and update
Diffstat (limited to 'examples/python/helloworld')
-rw-r--r--examples/python/helloworld/README.md3
-rw-r--r--[-rwxr-xr-x]examples/python/helloworld/greeter_client.py9
-rw-r--r--examples/python/helloworld/greeter_server.py6
3 files changed, 9 insertions, 9 deletions
diff --git a/examples/python/helloworld/README.md b/examples/python/helloworld/README.md
index 8fde0d2315..070b9e8837 100644
--- a/examples/python/helloworld/README.md
+++ b/examples/python/helloworld/README.md
@@ -91,9 +91,6 @@ Which internally invokes the proto-compiler as:
$ protoc -I ../../protos --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` ../../protos/helloworld.proto
```
-Optionally, you can just skip the code generation step as the generated python module has already
-been generated for you (helloworld_pb2.py).
-
### The client
Client-side code can be found in [greeter_client.py](greeter_client.py).
diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py
index 370ce46770..561b25bcb2 100755..100644
--- a/examples/python/helloworld/greeter_client.py
+++ b/examples/python/helloworld/greeter_client.py
@@ -29,15 +29,18 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
+from grpc.beta import implementations
+
import helloworld_pb2
_TIMEOUT_SECONDS = 10
def run():
- with helloworld_pb2.early_adopter_create_Greeter_stub('localhost', 50051) as stub:
- response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS)
- print "Greeter client received: " + response.message
+ channel = implementations.insecure_channel('localhost', 50051)
+ stub = helloworld_pb2.beta_create_Greeter_stub(channel)
+ response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS)
+ print "Greeter client received: " + response.message
if __name__ == '__main__':
diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py
index 81353666b1..1514d8f270 100644
--- a/examples/python/helloworld/greeter_server.py
+++ b/examples/python/helloworld/greeter_server.py
@@ -36,15 +36,15 @@ import helloworld_pb2
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
-class Greeter(helloworld_pb2.EarlyAdopterGreeterServicer):
+class Greeter(helloworld_pb2.BetaGreeterServicer):
def SayHello(self, request, context):
return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
def serve():
- server = helloworld_pb2.early_adopter_create_Greeter_server(
- Greeter(), 50051, None, None)
+ server = helloworld_pb2.beta_create_Greeter_server(Greeter())
+ server.add_insecure_port('[::]:50051')
server.start()
try:
while True: