Issue #26404: Add context manager to socketserver, by Aviv Palivoda

This commit is contained in:
Martin Panter 2016-04-13 00:36:52 +00:00
parent 7258176c68
commit 0cab9c1eba
11 changed files with 125 additions and 103 deletions

View file

@ -375,10 +375,9 @@ the current directory::
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
.. _http-server-cli: