@@ -41,17 +41,14 @@ def __init__(self, alias: str, params: dict) -> None:
41
41
def _get_enqueue_on_commit_for_task (self , task : Task ) -> bool :
42
42
"""
43
43
Determine the correct `enqueue_on_commit` setting to use for a given task.
44
-
45
- If the task defines it, use that, otherwise, fall back to the backend.
46
44
"""
47
- # If this project doesn't use a database, there's nothing to commit to
48
- if not connections .settings :
49
- return False
50
-
51
- if task .enqueue_on_commit is not None :
52
- return task .enqueue_on_commit
53
45
54
- return self .enqueue_on_commit
46
+ # If the task defines it, use that, otherwise, fall back to the backend.
47
+ return (
48
+ task .enqueue_on_commit
49
+ if task .enqueue_on_commit is not None
50
+ else self .enqueue_on_commit
51
+ )
55
52
56
53
def validate_task (self , task : Task ) -> None :
57
54
"""
@@ -121,8 +118,7 @@ async def aget_result(self, result_id: str) -> TaskResult:
121
118
122
119
def check (self , ** kwargs : Any ) -> Iterable [messages .CheckMessage ]:
123
120
if self .enqueue_on_commit and not connections .settings :
124
- yield messages .CheckMessage (
125
- messages .ERROR ,
121
+ yield messages .Error (
126
122
"`ENQUEUE_ON_COMMIT` cannot be used when no databases are configured" ,
127
123
hint = "Set `ENQUEUE_ON_COMMIT` to False" ,
128
124
)
0 commit comments