Skip to content

Commit

Permalink
Regress celery.states dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
EJH2 committed Oct 27, 2020
1 parent ab3b646 commit 50c3e3e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions celery_progress/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from celery.result import EagerResult, allow_join_result
from celery.backends.base import DisabledBackend
from celery import states


PROGRESS_STATE = 'PROGRESS'
Expand Down Expand Up @@ -60,7 +59,7 @@ def __init__(self, result):

def get_info(self):
response = {'state': self.result.state}
if self.result.state in [states.SUCCESS, states.FAILURE]:
if self.result.state in ['SUCCESS', 'FAILURE']:
success = self.result.successful()
with allow_join_result():
response.update({
Expand All @@ -69,7 +68,7 @@ def get_info(self):
'progress': _get_completed_progress(),
'result': self.result.get(self.result.id) if success else str(self.result.info),
})
elif self.result.state in states.EXCEPTION_STATES:
elif self.result.state in ['RETRY', 'REVOKED']:
if self.result.state == 'RETRY':
retry = self.result.info
when = str(retry.when) if isinstance(retry.when, datetime.datetime) else str(
Expand All @@ -89,7 +88,7 @@ def get_info(self):
'success': None,
'progress': self.result.info,
})
elif self.result.state in states.UNREADY_STATES:
elif self.result.state in ['PENDING', 'STARTED']:
response.update({
'complete': False,
'success': None,
Expand Down

0 comments on commit 50c3e3e

Please sign in to comment.