1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

Pass alias and params separately to backend

This commit is contained in:
Jake Howard 2024-10-17 17:12:06 +01:00
parent a6153630ad
commit c92a97267a
No known key found for this signature in database
GPG Key ID: 57AFB45680EDD477
3 changed files with 7 additions and 7 deletions

View File

@ -38,7 +38,7 @@ class TasksHandler(BaseConnectionHandler):
f"Could not find backend '{backend}': {e}" f"Could not find backend '{backend}': {e}"
) from e ) from e
return backend_cls({**params, "ALIAS": alias}) return backend_cls(alias=alias, params=params)
tasks = TasksHandler() tasks = TasksHandler()

View File

@ -24,10 +24,10 @@ class BaseTaskBackend(metaclass=ABCMeta):
supports_get_result = False supports_get_result = False
"""Can results be retrieved after the fact (from **any** thread / process)""" """Can results be retrieved after the fact (from **any** thread / process)"""
def __init__(self, options): def __init__(self, alias, params):
self.alias = options["ALIAS"] self.alias = alias
self.queues = set(options.get("QUEUES", [DEFAULT_QUEUE_NAME])) self.queues = set(params.get("QUEUES", [DEFAULT_QUEUE_NAME]))
self.enqueue_on_commit = bool(options.get("ENQUEUE_ON_COMMIT", True)) self.enqueue_on_commit = bool(params.get("ENQUEUE_ON_COMMIT", True))
def _get_enqueue_on_commit_for_task(self, task): def _get_enqueue_on_commit_for_task(self, task):
""" """

View File

@ -16,8 +16,8 @@ class DummyBackend(BaseTaskBackend):
supports_defer = True supports_defer = True
supports_async_task = True supports_async_task = True
def __init__(self, options) -> None: def __init__(self, alias, params) -> None:
super().__init__(options) super().__init__(alias, params)
self.results = [] self.results = []