From f36079f9f1e3585059e280a067b0bc21ead04bf0 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 2 Jun 2020 11:13:06 -0700 Subject: [PATCH] Add note about wait_for_termination --- content/docs/languages/python/basics.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/content/docs/languages/python/basics.md b/content/docs/languages/python/basics.md index bcc850b9398..b4f4adfd9eb 100644 --- a/content/docs/languages/python/basics.md +++ b/content/docs/languages/python/basics.md @@ -305,10 +305,14 @@ def serve(): RouteGuideServicer(), server) server.add_insecure_port('[::]:50051') server.start() + server.wait_for_termination() ``` -Because `start()` does not block you may need to sleep-loop if there is nothing -else for your code to do while serving. +The server `start()` method is non-blocking. A new thread will be instantiated +to handle requests. The thread calling `server.start()` will often +not have any other work to do in the meantime. In this case, you can call +`server.wait_for_termination()` to cleanly block the calling thread until the +server terminates. ### Creating the client {#client}