Skip to content

Commit

Permalink
feat: detect all celery processes (pantos-io#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
danut13 authored and juanmanuel-tirado committed Dec 18, 2024
1 parent f759918 commit b9ab53b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pantos/servicenode/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9ab53b

Please sign in to comment.