diff --git a/app/views/views.py b/app/views/views.py index 60b11027..74a6d7aa 100644 --- a/app/views/views.py +++ b/app/views/views.py @@ -2,7 +2,7 @@ import logging from celery.exceptions import TimeoutError -from celery.result import AsyncResult +# from celery.result import AsyncResult from celery.states import FAILURE, PENDING, SUCCESS from django.contrib.auth.decorators import login_required from django.core import serializers @@ -26,6 +26,7 @@ from app.worker.tasks import receiptor from app.worker.tasks.exporter import exporter from app.worker.tasks.importers import historical_data_importer +from reboot.celery import app logger = logging.getLogger(__name__) @@ -121,8 +122,9 @@ def poll_state(request: HttpRequest): request=request, err_msg="The task_id query parameter of the request was omitted.") - task = AsyncResult(task_id) + task = app.AsyncResult(task_id) res = JsonResponse(_poll_state(PENDING, 0, 200)) + print(f"!!! task id={task_id},state={task.state},successful={task.successful()},ready={task.ready()},failed={task.failed()}") if task.state == FAILURE or task.failed(): res = JsonResponse(_poll_state(FAILURE, 0, 400)) elif task.state == PROGRESS: @@ -146,8 +148,8 @@ def download_file(request: HttpRequest): while (attempts < ATTEMPT_LIMIT): try: attempts += 1 - task = AsyncResult(task_id) - result = task.get(timeout=0.5 * attempts) + task = app.AsyncResult(task_id) + result = task.get(timeout=1.0 * attempts) print(f"{task} {task_name} success #{attempts}: {result}") break except TimeoutError: