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
21 changes: 11 additions & 10 deletions django/tasks/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from collections.abc import Callable
from dataclasses import dataclass, field, replace
from datetime import datetime
from inspect import isclass, iscoroutinefunction
from typing import Any, Callable, Dict, Optional
from typing import Any

from asgiref.sync import async_to_sync, sync_to_async

Expand Down Expand Up @@ -43,10 +44,10 @@ class TaskResultStatus(TextChoices):
@dataclass(frozen=True, slots=True, kw_only=True)
class Task:
priority: int
func: Callable # The Task function.
func: Callable[..., Any] # The Task function.
backend: str
queue_name: str
run_after: Optional[datetime] # The earliest this Task will run.
run_after: datetime | None # The earliest this Task will run.

# Whether the Task receives the Task context when executed.
takes_context: bool = False
Expand Down Expand Up @@ -180,20 +181,20 @@ class TaskResult:

id: str # Unique identifier for the task result.
status: TaskResultStatus
enqueued_at: Optional[datetime] # Time the task was enqueued.
started_at: Optional[datetime] # Time the task was started.
finished_at: Optional[datetime] # Time the task was finished.
enqueued_at: datetime | None # Time the task was enqueued.
started_at: datetime | None # Time the task was started.
finished_at: datetime | None # Time the task was finished.

# Time the task was last attempted to be run.
last_attempted_at: Optional[datetime]
last_attempted_at: datetime | None

args: list # Arguments to pass to the task function.
kwargs: Dict[str, Any] # Keyword arguments to pass to the task function.
args: list[Any] # Arguments to pass to the task function.
kwargs: dict[str, Any] # Keyword arguments to pass to the task function.
backend: str
errors: list[TaskError] # Errors raised when running the task.
worker_ids: list[str] # Workers which have processed the task.

_return_value: Optional[Any] = field(init=False, default=None)
_return_value: Any | None = field(init=False, default=None)

def __post_init__(self):
object.__setattr__(self, "args", normalize_json(self.args))
Expand Down
4 changes: 2 additions & 2 deletions scripts/test_new_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ django-admin startproject test_one
cd test_one
./manage.py --help # Ensure executable bits
python manage.py migrate
python manage.py runserver
python manage.py runserver 0

deactivate
cd ..
Expand All @@ -40,7 +40,7 @@ django-admin startproject test_one
cd test_one
./manage.py --help # Ensure executable bits
python manage.py migrate
python manage.py runserver
python manage.py runserver 0

deactivate
cd ..
Expand Down