diff options
author | ncteisen <ncteisen@gmail.com> | 2017-12-12 10:31:47 -0800 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-12-12 10:59:01 -0800 |
commit | 848a749f7afb19c79188c328e44f53fc2f7695e2 (patch) | |
tree | 942b8a079b12bc7742ec493888d62ba43afcc7a0 /examples/python/helloworld | |
parent | 8cfaf4ec4fd2aa5197487664aea3a586f1217bad (diff) |
yapf examples/python
Diffstat (limited to 'examples/python/helloworld')
-rw-r--r-- | examples/python/helloworld/greeter_client.py | 11 | ||||
-rw-r--r-- | examples/python/helloworld/greeter_server.py | 26 |
2 files changed, 18 insertions, 19 deletions
diff --git a/examples/python/helloworld/greeter_client.py b/examples/python/helloworld/greeter_client.py index d9b2bdfd07..a0aeb47bd7 100644 --- a/examples/python/helloworld/greeter_client.py +++ b/examples/python/helloworld/greeter_client.py @@ -11,7 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """The Python implementation of the GRPC helloworld.Greeter client.""" from __future__ import print_function @@ -23,11 +22,11 @@ import helloworld_pb2_grpc def run(): - channel = grpc.insecure_channel('localhost:50051') - stub = helloworld_pb2_grpc.GreeterStub(channel) - response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) - print("Greeter client received: " + response.message) + channel = grpc.insecure_channel('localhost:50051') + stub = helloworld_pb2_grpc.GreeterStub(channel) + response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) + print("Greeter client received: " + response.message) if __name__ == '__main__': - run() + run() diff --git a/examples/python/helloworld/greeter_server.py b/examples/python/helloworld/greeter_server.py index be61695616..c355662ef8 100644 --- a/examples/python/helloworld/greeter_server.py +++ b/examples/python/helloworld/greeter_server.py @@ -11,7 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - """The Python implementation of the GRPC helloworld.Greeter server.""" from concurrent import futures @@ -27,20 +26,21 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24 class Greeter(helloworld_pb2_grpc.GreeterServicer): - def SayHello(self, request, context): - return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) + def SayHello(self, request, context): + return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) def serve(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) - server.add_insecure_port('[::]:50051') - server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) + server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) + helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) + server.add_insecure_port('[::]:50051') + server.start() + try: + while True: + time.sleep(_ONE_DAY_IN_SECONDS) + except KeyboardInterrupt: + server.stop(0) + if __name__ == '__main__': - serve() + serve() |