Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/celery_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
]

_vhost_apps = {}
# Function to get the app for a vhost


def app_for_vhost(vhost):
# Function to get the app for a vhost
if vhost not in _vhost_apps:
# Take the CELERY_BROKER_URL and replace the vhost with the vhhost for this queue
broker_url = settings.CELERY_BROKER_URL
Expand All @@ -26,13 +28,11 @@ def app_for_vhost(vhost):
urllib.parse.uses_relative.append(scheme)
urllib.parse.uses_netloc.append(scheme)
broker_url = urllib.parse.urljoin(broker_url, vhost)

vhost_app = Celery()
# Copy the settings so we can modify the broker url to include the vhost
django_settings = copy.copy(settings)
django_settings.CELERY_BROKER_URL = broker_url
vhost_app.config_from_object(django_settings, namespace='CELERY')
vhost_app.task_queues = app.conf.task_queues
_vhost_apps[vhost] = vhost_app

return _vhost_apps[vhost]
return _vhost_apps[vhost]