diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-04-13 00:36:52 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-04-13 00:36:52 (GMT) |
commit | 0cab9c1ebaa11bb7838a552c671c903156262ab7 (patch) | |
tree | 640bcabc8876c74c7ba53231551613cfb9a34600 /Doc/library/http.server.rst | |
parent | 7258176c68a5061a5d05ee43f11e99fd94e34364 (diff) | |
download | cpython-0cab9c1ebaa11bb7838a552c671c903156262ab7.zip cpython-0cab9c1ebaa11bb7838a552c671c903156262ab7.tar.gz cpython-0cab9c1ebaa11bb7838a552c671c903156262ab7.tar.bz2 |
Issue #26404: Add context manager to socketserver, by Aviv Palivoda
Diffstat (limited to 'Doc/library/http.server.rst')
-rw-r--r-- | Doc/library/http.server.rst | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index 0bde35b..7ab249a 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -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: |