mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
Cleanup from first pass review
This commit is contained in:
parent
975fbdfbe8
commit
673f061ee2
@ -13,6 +13,7 @@ from .task import (
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"tasks",
|
"tasks",
|
||||||
|
"default_task_backend",
|
||||||
"DEFAULT_TASK_BACKEND_ALIAS",
|
"DEFAULT_TASK_BACKEND_ALIAS",
|
||||||
"DEFAULT_QUEUE_NAME",
|
"DEFAULT_QUEUE_NAME",
|
||||||
"task",
|
"task",
|
||||||
@ -26,10 +27,7 @@ class TasksHandler(BaseConnectionHandler):
|
|||||||
exception_class = InvalidTaskBackendError
|
exception_class = InvalidTaskBackendError
|
||||||
|
|
||||||
def create_connection(self, alias):
|
def create_connection(self, alias):
|
||||||
params = self.settings[alias].copy()
|
params = self.settings[alias]
|
||||||
|
|
||||||
# Added back to allow a backend to self-identify
|
|
||||||
params["ALIAS"] = alias
|
|
||||||
|
|
||||||
backend = params["BACKEND"]
|
backend = params["BACKEND"]
|
||||||
|
|
||||||
@ -40,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)
|
return backend_cls({**params, "ALIAS": alias})
|
||||||
|
|
||||||
|
|
||||||
tasks = TasksHandler()
|
tasks = TasksHandler()
|
||||||
|
@ -39,7 +39,7 @@ class BaseTaskBackend(metaclass=ABCMeta):
|
|||||||
if not connections.settings:
|
if not connections.settings:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if isinstance(task.enqueue_on_commit, bool):
|
if task.enqueue_on_commit is not None:
|
||||||
return task.enqueue_on_commit
|
return task.enqueue_on_commit
|
||||||
|
|
||||||
return self.enqueue_on_commit
|
return self.enqueue_on_commit
|
||||||
|
@ -8,7 +8,4 @@ def check_tasks(app_configs=None, **kwargs):
|
|||||||
from django.tasks import tasks
|
from django.tasks import tasks
|
||||||
|
|
||||||
for backend in tasks.all():
|
for backend in tasks.all():
|
||||||
try:
|
yield from backend.check()
|
||||||
yield from backend.check()
|
|
||||||
except NotImplementedError:
|
|
||||||
pass
|
|
||||||
|
@ -3,7 +3,7 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
|
|||||||
|
|
||||||
class InvalidTaskError(Exception):
|
class InvalidTaskError(Exception):
|
||||||
"""
|
"""
|
||||||
The provided task function is invalid.
|
The provided task is invalid.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user