From c1d3f0c99c90d94de346fcc4eb434cadf5804543 Mon Sep 17 00:00:00 2001 From: Danut Date: Fri, 23 Aug 2024 16:42:19 +0200 Subject: [PATCH] feat: detect all celery processes (#88) --- 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