Skip to content

Commit

Permalink
progress.pending indicates if a task was started
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarWKH committed Sep 7, 2020
1 parent 314e232 commit e93b096
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions celery_progress/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def set_progress(self, current, total, description=""):
self.task.update_state(
state=PROGRESS_STATE,
meta={
'pending': False,
'current': current,
'total': total,
'percent': percent,
Expand All @@ -53,6 +54,7 @@ def stop_task(self, current, total, exc):
self.task.update_state(
state='FAILURE',
meta={
'pending': False,
'current': current,
'total': total,
'percent': 100.0,
Expand Down Expand Up @@ -88,22 +90,23 @@ def get_info(self):
return {
'complete': False,
'success': None,
'progress': _get_unknown_progress(),
'progress': _get_unknown_progress(self.result.state),
}
return self.result.info


def _get_completed_progress():
return {
'pending': False,
'current': 100,
'total': 100,
'percent': 100,
}


def _get_unknown_progress():
def _get_unknown_progress(state):
return {
'pending': True,
'pending': state == 'PENDING',
'current': 0,
'total': 100,
'percent': 0,
Expand Down

0 comments on commit e93b096

Please sign in to comment.