From eb8f17413fafc06f8601cc18fd49653202a060e7 Mon Sep 17 00:00:00 2001 From: Omar Khashoggi Date: Thu, 25 Mar 2021 22:08:30 +0300 Subject: [PATCH 1/2] log unknown state --- celery_progress/backend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/celery_progress/backend.py b/celery_progress/backend.py index baba989..ee6f529 100644 --- a/celery_progress/backend.py +++ b/celery_progress/backend.py @@ -1,10 +1,12 @@ import datetime +import logging from abc import ABCMeta, abstractmethod from decimal import Decimal from celery.result import EagerResult, allow_join_result from celery.backends.base import DisabledBackend +logger = logging.getLogger(__name__) PROGRESS_STATE = 'PROGRESS' @@ -102,11 +104,12 @@ def get_info(self): 'progress': _get_unknown_progress(self.result.state), }) else: + logger.error('Task %s has unknown state %s with metadata %s', self.result.id, self.result.state, self.result.info) response.update({ 'complete': True, 'success': False, 'progress': _get_unknown_progress(self.result.state), - 'result': 'Unknown state {}'.format(str(self.result.info)), + 'result': 'Unknown state {}: {}'.format(self.result.state, str(self.result.info)), }) return response From 807da7b49a36b4fe4d5e09756cbe6d5ee3138a2e Mon Sep 17 00:00:00 2001 From: Omar Khashoggi Date: Thu, 25 Mar 2021 22:55:12 +0300 Subject: [PATCH 2/2] remove unnecessary details of unknown states --- celery_progress/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/celery_progress/backend.py b/celery_progress/backend.py index ee6f529..bf3cbd1 100644 --- a/celery_progress/backend.py +++ b/celery_progress/backend.py @@ -109,7 +109,7 @@ def get_info(self): 'complete': True, 'success': False, 'progress': _get_unknown_progress(self.result.state), - 'result': 'Unknown state {}: {}'.format(self.result.state, str(self.result.info)), + 'result': 'Unknown state {}'.format(self.result.state), }) return response