Changing the port helps:
<code>
server = HTTPServer(('', 8001), RequestHandler)
webbrowser.open('http://localhost:8001', stop_when_done = True)
</code>
This works as I expected: "Done" closes the browser and the server exits. No restart needed.
Weird: When I omit the stop_when_done parameter, it works with port 80 but hangs with port 8001?! In all cases browser and server start and run fine, only sometimes the server won't quit, "stop" button not working. So it probably has nothing to do with privileged ports, right?
I'm lost here, can't explain that. Any ideas? I'm an absolute beginner in Python, so am I maybe missing something obvious? E.g. is this behaviour perfectly normal and to be expected from Python?