From 5fcdc98b7fdd580b2612f79c0117acb31c9273a5 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 6 Nov 2020 01:01:06 +0100 Subject: [PATCH] Fix unit test error due the PID 1 problem when inside a container --- unittests/test_schedulers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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