From 2a2c43f6b11d8ca2d8ada8d3b2fdc83d21f16c20 Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Sat, 3 Dec 2022 09:27:34 +0300 Subject: [PATCH] Try to catch / workaround 5215 (#5216) Fixes #5215 It's not really clear how the error can be obtained, but this PR adds a workaround for the problem. There are 2 possible ways to get the `message` parameter - from an error and from the operation status. - Our status messages are always represented by a string, no any other values is assigned. - rq is trickier here - it receives rq data and [decodes it](https://github.com/rq/rq/blob/master/rq/job.py#L603-L609) if there is an error, but the operations can leave None as the `exc_info` value. Maybe [this issue](https://github.com/rq/rq/issues/1633) is relevant here. --- cvat/apps/engine/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index d507d7e9..64c7dfe3 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -1221,10 +1221,14 @@ class TaskViewSet(viewsets.GenericViewSet, mixins.ListModelMixin, elif job.is_queued: response = { "state": "Queued" } elif job.is_failed: - response = { "state": "Failed", "message": job.exc_info } + # FIXME: It seems that in some cases exc_info can be None. + # It's not really clear how it is possible, but it can + # lead to an error in serializing the response + # https://github.com/opencv/cvat/issues/5215 + response = { "state": "Failed", "message": job.exc_info or "Unknown error" } else: response = { "state": "Started" } - if 'status' in job.meta: + if job.meta.get('status'): response['message'] = job.meta['status'] response['progress'] = job.meta.get('task_progress', 0.)