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

Method test_shutdown

Lib/test/test_socketserver.py:250–273  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

248
249 @threading_helper.reap_threads
250 def test_shutdown(self):
251 # Issue #2302: shutdown() should always succeed in making an
252 # other thread leave serve_forever().
253 class MyServer(socketserver.TCPServer):
254 pass
255
256 class MyHandler(socketserver.StreamRequestHandler):
257 pass
258
259 threads = []
260 for i in range(20):
261 s = MyServer((HOST, 0), MyHandler)
262 t = threading.Thread(
263 name='MyServer serving',
264 target=s.serve_forever,
265 kwargs={'poll_interval':0.01})
266 t.daemon = True # In case this function raises.
267 threads.append((t, s))
268 for t, s in threads:
269 t.start()
270 s.shutdown()
271 for t, s in threads:
272 t.join()
273 s.server_close()
274
275 def test_close_immediately(self):
276 class MyServer(socketserver.ThreadingMixIn, socketserver.TCPServer):

Callers

nothing calls this directly

Calls 6

startMethod · 0.95
joinMethod · 0.95
MyServerClass · 0.70
appendMethod · 0.45
shutdownMethod · 0.45
server_closeMethod · 0.45

Tested by

no test coverage detected