From 83b16c228b3a17ad582ea92b9da061653fd17a49 Mon Sep 17 00:00:00 2001 From: Danut Ilisei Date: Fri, 23 Aug 2024 11:10:03 +0200 Subject: [PATCH] feat: detect all celery processes --- pantos/servicenode/celery.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pantos/servicenode/celery.py b/pantos/servicenode/celery.py index 186e032..7e43e7c 100644 --- a/pantos/servicenode/celery.py +++ b/pantos/servicenode/celery.py @@ -24,7 +24,17 @@ def is_main_module() -> bool: - return __name__ == '__main__' or any('celery' in arg for arg in sys.argv) + """Determine if the current process is a Celery worker process. + + Returns + ------- + bool + True if the current process is a Celery worker process. + + """ + potential_celery_markers = ['celery', 'worker', 'beat', 'flower'] + return (__name__ == '__main__' + or any(marker in sys.argv for marker in potential_celery_markers)) if is_main_module(): # pragma: no cover