Commit e29e2e6c authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

Fix registration of periodic tasks

According to
https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html?highlight=periodic#entries,
since we are adding periodic tasks in a callback in a task module,
we need to use the `on_after_finalize` signal, rather than
`on_after_configure`.

I also had to make some small changes to the app finalization that
I worked out by trial and error.

Fixes #363.
parent 3addadd3
......@@ -17,7 +17,7 @@ __version__ = get_versions()['version']
del get_versions
# Use redis broker, because it supports locks (and thus singleton tasks).
app = Celery(__name__, broker='redis://', autofinalize=False)
app = Celery(__name__, broker='redis://', config_source=playground)
"""Celery application object."""
# Register email, LVAlert and VOEvent subsystems.
......@@ -28,10 +28,6 @@ voevent.install(app)
# Register all tasks.
app.autodiscover_tasks([__name__])
# Add default configuration.
app.add_defaults(playground)
app.finalize()
# Customize configuration from environment variable.
app.config_from_envvar('CELERY_CONFIG_MODULE', silent=True)
......
......@@ -143,7 +143,7 @@ def _upload_psd(graceid):
gracedb.upload(psd, 'psd.xml.gz', graceid, 'Noise PSD', ['psd'])
@app.on_after_configure.connect
@app.on_after_finalize.connect
def setup_periodic_tasks(sender, **kwargs):
"""Register periodic tasks.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment