Add note about wait_for_termination (#260)

This commit is contained in:
Richard Belleville 2020-06-02 11:37:16 -07:00 committed by GitHub
parent 9232a3fcd1
commit 810f55bec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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}