From ebac57df04779cd7485fca025a12451e7259af18 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Mon, 6 May 2024 14:14:36 -0400 Subject: [PATCH] don't kill if pid same as file (#8997) (#8998) The pid file needs to be deleted. --- celery/platforms.py | 1 + t/unit/utils/test_platforms.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/celery/platforms.py b/celery/platforms.py index 1375fd82c0b..a9c30a3251e 100644 --- a/celery/platforms.py +++ b/celery/platforms.py @@ -188,6 +188,7 @@ def remove_if_stale(self): return True if pid == os.getpid(): # this can be common in k8s pod with PID of 1 - don't kill + self.remove() return True try: diff --git a/t/unit/utils/test_platforms.py b/t/unit/utils/test_platforms.py index 3f4e47ae339..fdac88288dc 100644 --- a/t/unit/utils/test_platforms.py +++ b/t/unit/utils/test_platforms.py @@ -696,7 +696,7 @@ def test_remove_if_stale_same_pid(self): p.remove = Mock() assert p.remove_if_stale() - p.remove.assert_not_called() + p.remove.assert_called_with() @patch('os.fsync') @patch('os.getpid')