Skip to content

Commit

Permalink
feat: detect all celery processes
Browse files Browse the repository at this point in the history
  • Loading branch information
danut13 committed Aug 23, 2024
1 parent a61e5d7 commit 83b16c2
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 83b16c2

Please sign in to comment.