# HG changeset patch # Parent 33db20c8537cc5be58753788d04672e66542dd90 diff -r 33db20c8537c Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst Sat Jan 31 02:45:12 2015 -0800 +++ b/Doc/library/socketserver.rst Fri Feb 27 23:29:59 2015 +0000 @@ -33,9 +33,10 @@ handler class by subclassing the :class:`BaseRequestHandler` class and overriding its :meth:`handle` method; this method will process incoming requests. Second, you must instantiate one of the server classes, passing it -the server's address and the request handler class. Finally, call the +the server's address and the request handler class. Then call the :meth:`handle_request` or :meth:`serve_forever` method of the server object to -process one or many requests. +process one or many requests. Finally, call :meth:`~BaseServer.server_close` +to close the socket. When inheriting from :class:`ThreadingMixIn` for threaded connection behavior, you should explicitly declare how you want your threads to behave on an abrupt @@ -164,6 +165,11 @@ Added ``service_actions`` call to the ``serve_forever`` method. +.. method:: BaseServer.server_close() + + Clean up the server. May be overridden. + + .. method:: BaseServer.service_actions() This is called in the :meth:`serve_forever` loop. This method can be @@ -547,6 +553,7 @@ client(ip, port, "Hello World 3") server.shutdown() + server.server_close() The output of the example should look something like this:: diff -r 33db20c8537c Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py Sat Jan 31 02:45:12 2015 -0800 +++ b/Lib/test/test_socketserver.py Fri Feb 27 23:29:59 2015 +0000 @@ -145,6 +145,7 @@ server.shutdown() t.join() server.server_close() + self.assertEqual(server.socket.fileno(), -1) if verbose: print("done") def stream_examine(self, proto, addr):