Skip to content

Commit f194474

Browse files
committed
Pass alias and params separately to backend
1 parent f13aa48 commit f194474

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

django_tasks/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create_connection(self, alias: str) -> BaseTaskBackend:
6262
f"Could not find backend '{backend}': {e}"
6363
) from e
6464

65-
return backend_cls({**params, "ALIAS": alias}) # type:ignore[no-any-return]
65+
return backend_cls(alias=alias, params=params) # type:ignore[no-any-return]
6666

6767

6868
tasks = TasksHandler()

django_tasks/backends/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class BaseTaskBackend(metaclass=ABCMeta):
3131
supports_get_result = False
3232
"""Can results be retrieved after the fact (from **any** thread / process)"""
3333

34-
def __init__(self, options: dict) -> None:
34+
def __init__(self, alias: str, params: dict) -> None:
3535
from django_tasks import DEFAULT_QUEUE_NAME
3636

37-
self.alias = options["ALIAS"]
38-
self.queues = set(options.get("QUEUES", [DEFAULT_QUEUE_NAME]))
39-
self.enqueue_on_commit = bool(options.get("ENQUEUE_ON_COMMIT", True))
37+
self.alias = alias
38+
self.queues = set(params.get("QUEUES", [DEFAULT_QUEUE_NAME]))
39+
self.enqueue_on_commit = bool(params.get("ENQUEUE_ON_COMMIT", True))
4040

4141
def _get_enqueue_on_commit_for_task(self, task: Task) -> bool:
4242
"""

django_tasks/backends/dummy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class DummyBackend(BaseTaskBackend):
2323
supports_async_task = True
2424
results: List[TaskResult]
2525

26-
def __init__(self, options: dict) -> None:
27-
super().__init__(options)
26+
def __init__(self, alias: str, params: dict) -> None:
27+
super().__init__(alias, params)
2828

2929
self.results = []
3030

0 commit comments

Comments
 (0)