| 134 | |
| 135 | |
| 136 | def init(force_browser_process_termination): |
| 137 | utils.delete_file(browser_spawn_lock_filename) |
| 138 | utils.delete_file(f'{browser_spawn_lock_filename}_counter') |
| 139 | if force_browser_process_termination or os.getenv('EMTEST_FORCE_BROWSER_PROCESS_TERMINATION'): |
| 140 | config = get_browser_config() |
| 141 | |
| 142 | if config and hasattr(config, 'executable_name'): |
| 143 | def terminate_all_browser_processes(): |
| 144 | procs = list_processes_by_name(config.executable_name) |
| 145 | if len(procs) > 0: |
| 146 | print(f'Terminating {len(procs)} stray browser processes.') |
| 147 | terminate_list_of_processes(procs) |
| 148 | |
| 149 | atexit.register(terminate_all_browser_processes) |
| 150 | terminate_all_browser_processes() |
| 151 | |
| 152 | |
| 153 | def find_browser_test_file(filename): |