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

Function tearDownModule

Lib/test/_test_multiprocessing.py:7409–7436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7407 multiprocessing.get_logger().setLevel(LOG_LEVEL)
7408
7409 def tearDownModule():
7410 need_sleep = False
7411
7412 # bpo-26762: Some multiprocessing objects like Pool create reference
7413 # cycles. Trigger a garbage collection to break these cycles.
7414 test.support.gc_collect()
7415
7416 multiprocessing.set_start_method(old_start_method[0], force=True)
7417 # pause a bit so we don't get warning about dangling threads/processes
7418 processes = set(multiprocessing.process._dangling) - set(dangling[0])
7419 if processes:
7420 need_sleep = True
7421 test.support.environment_altered = True
7422 support.print_warning(f'Dangling processes: {processes}')
7423 processes = None
7424
7425 threads = set(threading._dangling) - set(dangling[1])
7426 if threads:
7427 need_sleep = True
7428 test.support.environment_altered = True
7429 support.print_warning(f'Dangling threads: {threads}')
7430 threads = None
7431
7432 # Sleep 500 ms to give time to child processes to complete.
7433 if need_sleep:
7434 time.sleep(0.5)
7435
7436 multiprocessing.util._cleanup_tests()
7437
7438 remote_globs['setUpModule'] = setUpModule
7439 remote_globs['tearDownModule'] = tearDownModule

Callers

nothing calls this directly

Calls 3

setFunction · 0.85
set_start_methodMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…