Two suggestions:

1. Add a `time.sleep(0.5)` in there.
2. Do a `for` loop, to avoid any potential case where the server doesn't wind up stopping and we get an infinite loop here.  Not just in the current code, but in case the code gets changed too.