Skip to content
Snippets Groups Projects
Verified Commit 94b1f541 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Improve return value of celery_optional task

parent 4627d10e
No related branches found
No related tags found
1 merge request!389Add data check system
Pipeline #5040 passed
......@@ -195,6 +195,12 @@ def celery_optional(orig: Callable) -> Callable:
If Celery is configured and available, it wraps the function in a Task
and calls its delay method when invoked; if not, it leaves it untouched
and it is executed synchronously.
The wrapped function returns a tuple with either
the return value of the task's delay method and False
if the method has been executed asynchronously
or the return value of the executed method and True
if the method has been executed synchronously.
"""
if is_celery_enabled():
from ..celery import app # noqa
......@@ -203,10 +209,9 @@ def celery_optional(orig: Callable) -> Callable:
def wrapped(*args, **kwargs):
if is_celery_enabled():
task.delay(*args, **kwargs)
return task.delay(*args, **kwargs), False
else:
orig(*args, **kwargs)
return True
return orig(*args, **kwargs), True
return wrapped
......
......@@ -728,7 +728,7 @@ class RunDataChecks(PermissionRequiredMixin, View):
permission_required = "core.run_data_checks"
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
if not check_data():
if not check_data()[1]:
messages.success(
request,
_(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment