Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions django_tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

from .backends.base import BaseTaskBackend
from .exceptions import InvalidTaskBackendError
from .task import DEFAULT_QUEUE_NAME, ResultStatus, Task, task
from .task import (
DEFAULT_QUEUE_NAME,
DEFAULT_TASK_BACKEND_ALIAS,
ResultStatus,
Task,
task,
)

__version__ = "0.0.0"

Expand All @@ -24,8 +30,6 @@
"Task",
]

DEFAULT_TASK_BACKEND_ALIAS = "default"


class TasksHandler(BaseConnectionHandler[BaseTaskBackend]):
settings_name = "TASKS"
Expand All @@ -38,7 +42,7 @@ def configure_settings(self, settings: Optional[dict]) -> dict:
# HACK: Force a default task backend.
# Can be replaced with `django.conf.global_settings` once vendored.
return {
"default": {
DEFAULT_TASK_BACKEND_ALIAS: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: As discussed, we should document that it should be called "default" (as with DATABASES).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But even if discarding the rest of the PR, we could still reference that variable instead of writing default again, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_TASK_BACKEND_ALIAS isn't really part of the public API, so people shouldn't need to use it.

"BACKEND": "django_tasks.backends.immediate.ImmediateBackend"
}
}
Expand Down
3 changes: 2 additions & 1 deletion django_tasks/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
if TYPE_CHECKING:
from .backends.base import BaseTaskBackend

DEFAULT_TASK_BACKEND_ALIAS = "default"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really not sure about the location of that constant. The locations where I wanted to put it produced circular imports, though...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is why I just duplicated it instead. Tests should cover if they're different.

DEFAULT_QUEUE_NAME = "default"


Expand Down Expand Up @@ -151,7 +152,7 @@ def module_path(self) -> str:
def task(
priority: int = 0,
queue_name: str = DEFAULT_QUEUE_NAME,
backend: str = "default",
backend: str = DEFAULT_TASK_BACKEND_ALIAS,
) -> Callable[[Callable[P, T]], Task[P, T]]:
"""
A decorator used to create a task.
Expand Down