Coverage for gwcelery/__init__.py: 96%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-11-14 05:52 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-11-14 05:52 +0000
1"""Celery application initialization."""
3import sys
5from celery import Celery
7from . import email, igwn_alert, kafka, sentry, voevent
8from ._version import get_versions
9from .conf import playground
11__all__ = ('app',)
13__version__ = get_versions()['version']
14del get_versions
16# Use redis broker, because it supports locks (and thus singleton tasks).
17app = Celery(__name__, broker='redis://', config_source=playground)
18"""Celery application object."""
20# Register email, LVAlert and VOEvent subsystems.
21email.install(app)
22igwn_alert.install(app)
23voevent.install(app)
24kafka.install(app)
26# Register all tasks.
27app.autodiscover_tasks([__name__])
29# Customize configuration from environment variable.
30app.config_from_envvar('CELERY_CONFIG_MODULE', silent=True)
32# Use the same URL for both the result backend and the broker.
33app.conf['result_backend'] = app.conf.broker_url
35sentry.configure()
38def main(argv=None):
39 if argv is None:
40 argv = sys.argv
41 argv = argv[1:] # Strip off the script name; click doesn't want it.
42 app.start(argv) # The application can take it from here!