Skip to content

Commit

Permalink
api: queue_position only if queued
Browse files Browse the repository at this point in the history
This is a cleaner API call, no queue position means it's currently
running, -1 means it's not supported by the server, e.g. old Redis
version.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Aug 14, 2021
1 parent f74890e commit 69cef35
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions asu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,17 @@ def return_job(job):
status = 500
response["message"] = job.exc_info.strip().split("\n")[-1]

elif job.is_queued or job.is_started:
elif job.is_queued:
status = 202
response = {
"status": job.get_status(),
"queue_position": job.get_position() or -1,
}

elif job.is_started:
status = 202
response = {
"status": job.get_status(),
"queue_position": job.get_position() or 0,
}

elif job.is_finished:
Expand Down

0 comments on commit 69cef35

Please sign in to comment.