Remove dependecies from celery_once customizations
Situation
Alliance Auth is using the third party library celery-once, which allows to prevent multiple execution and queuing of tasks. As part of the configuration it has defined it's own QueueOnce
class with custom defaults, and it's own backend for locking. QueueOnce
is a popular feature in Alliance Auth and community apps.
Problem
The customization implementations are currently located in allianceauth.services.tasks
, where they are mixed up with other task related components. Those other components require Django to be fully up and running to function (e.g. the User model needs to be available). This creates an unnecessary dependency and e.g. prevents celery-once from being used during Django startup.
While removing unnecessary dependencies always is a good thing, this dependency specifically prevents me from using celery once in one of my apps.
Solution
This change removes that dependency by putting all celery once related components into their own package (allianceauth.services.celery_once
). The external interface - i.e. the QueueOnce
class - remains available from allianceauth.services.tasks
to ensure backwards compatibility. Note that admins will need to adjust their local celery configuration (myauth/celery.py
) for this change as follows:
...
app.conf.ONCE = {
'backend': 'allianceauth.services.celery_once.backends.DjangoBackend',
'settings': {}
}
...