From 69cef357af445148928bca32cab5152e09dfb59e Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Fri, 13 Aug 2021 14:53:32 -1000 Subject: [PATCH] api: queue_position only if queued 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 --- asu/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/asu/api.py b/asu/api.py index c651481a..8fbf8f2a 100644 --- a/asu/api.py +++ b/asu/api.py @@ -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: