Skip to content

Commit

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

Please sign in to comment.