14 """Tests clean shutdown of server on various interpreter exit conditions.
16 The tests in this module spawn a subprocess for each test case, the
17 test is considered successful if it doesn't freeze/timeout.
28 from tests.unit import _server_shutdown_scenarios
30 SCENARIO_FILE = os.path.abspath(
31 os.path.join(os.path.dirname(os.path.realpath(__file__)),
32 '_server_shutdown_scenarios.py'))
33 INTERPRETER = sys.executable
34 BASE_COMMAND = [INTERPRETER, SCENARIO_FILE]
37 process_lock = threading.Lock()
44 for process
in processes:
51 atexit.register(cleanup_processes)
56 processes.append(process)
65 process = subprocess.Popen(
66 BASE_COMMAND + [_server_shutdown_scenarios.SERVER_DEALLOCATED],
72 process = subprocess.Popen(
73 BASE_COMMAND + [_server_shutdown_scenarios.SERVER_RAISES_EXCEPTION],
78 @unittest.skipIf(os.name ==
'nt',
'fork not supported on windows')
80 process = subprocess.Popen(
81 BASE_COMMAND + [_server_shutdown_scenarios.SERVER_FORK_CAN_EXIT],
87 if __name__ ==
'__main__':
89 unittest.main(verbosity=2)