未验证 提交 2a2c43f6 编写于 作者: M Maxim Zhiltsov 提交者: GitHub

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.
上级 d4788ee6
......@@ -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.)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册