bpo-31151: Add socketserver.ForkingMixIn.server_close() (#3057)

* Add socketserver.ForkingMixIn.server_close()

bpo-31151: socketserver.ForkingMixIn.server_close() now waits until
all child processes completed to prevent leaking zombie processes.

* Fix test on Windows which doesn't have ForkingMixIn
This commit is contained in:
Victor Stinner 2017-08-10 15:28:16 +02:00 committed by GitHub
parent 6c8c2943d9
commit aa8ec34ad5
3 changed files with 14 additions and 6 deletions

View file

@ -144,6 +144,10 @@ class SocketServerTest(unittest.TestCase):
t.join()
server.server_close()
self.assertEqual(-1, server.socket.fileno())
if HAVE_FORKING and isinstance(server, socketserver.ForkingMixIn):
# bpo-31151: Check that ForkingMixIn.server_close() waits until
# all children completed
self.assertFalse(server.active_children)
if verbose: print("done")
def stream_examine(self, proto, addr):
@ -371,10 +375,7 @@ class ThreadingErrorTestServer(socketserver.ThreadingMixIn,
if HAVE_FORKING:
class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer):
def wait_done(self):
[child] = self.active_children
os.waitpid(child, 0)
self.active_children.clear()
pass
class SocketWriterTest(unittest.TestCase):