diff --git a/unittests/test_schedulers.py b/unittests/test_schedulers.py index e00d6f1175..7d465f6482 100644 --- a/unittests/test_schedulers.py +++ b/unittests/test_schedulers.py @@ -483,7 +483,13 @@ def state(self): def assert_process_died(pid): try: os.kill(pid, 0) - pytest.fail('process %s is still alive' % pid) + if os.getpid() == 1: + # We are running in a container; so pid is likely a zombie; reap it + if os.waitpid(pid, os.WNOHANG)[0] == 0: + pytest.fail(f'process {pid} is still alive') + else: + pytest.fail(f'process {pid} is still alive') + except (ProcessLookupError, PermissionError): pass