diff --git a/tests/cli/commands/test_internal_api_command.py b/tests/cli/commands/test_internal_api_command.py index 2959cfa9f6f59..d821cc0246e44 100644 --- a/tests/cli/commands/test_internal_api_command.py +++ b/tests/cli/commands/test_internal_api_command.py @@ -141,9 +141,13 @@ def test_cli_internal_api_background(self, tmp_path): "[magenta]Terminating monitor process and expect " "internal-api and gunicorn processes to terminate as well" ) + internal_api_proc = psutil.Process(pid_internal_api) + internal_api_proc.terminate() proc = psutil.Process(pid_monitor) proc.terminate() - assert proc.wait(120) in (0, None) + gone, alive = psutil.wait_procs([internal_api_proc, proc], timeout=120) + for p in alive: + p.kill() self._check_processes(ignore_running=False) console.print("[magenta]All internal-api and gunicorn processes are terminated.") except Exception: