MCPcopy Index your code
hub / github.com/python/cpython / test_threads_reaped

Method test_threads_reaped

Lib/test/test_socketserver.py:501–515  ·  view source on GitHub ↗

In #37193, users reported a memory leak due to the saving of every request thread. Ensure that not all threads are kept forever.

(self)

Source from the content-addressed store, hash-verified

499 server.server_close()
500
501 def test_threads_reaped(self):
502 """
503 In #37193, users reported a memory leak
504 due to the saving of every request thread. Ensure that
505 not all threads are kept forever.
506 """
507 class MyServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
508 pass
509
510 server = MyServer((HOST, 0), socketserver.StreamRequestHandler)
511 for n in range(10):
512 with socket.create_connection(server.server_address):
513 server.handle_request()
514 self.assertLess(len(server._threads), 10)
515 server.server_close()
516
517
518class TestModule(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

MyServerClass · 0.70
create_connectionMethod · 0.45
handle_requestMethod · 0.45
assertLessMethod · 0.45
server_closeMethod · 0.45

Tested by

no test coverage detected