returning 503 Service Unavailable when requested task type is not available

This commit is contained in:
Andreas Köpf
2023-01-11 13:56:21 +01:00
parent 78306b7ca2
commit 0117159da0
+5 -2
View File
@@ -1,5 +1,6 @@
import random
from enum import Enum
from http import HTTPStatus
from typing import Optional, Tuple
from uuid import UUID
@@ -217,14 +218,16 @@ class TreeManager:
if task_type == TaskType.NONE:
raise OasstError(
f"No tasks of type '{desired_task_type.value}' are currently available.",
OasstErrorCode.TASK_REQUESTED_TYPE_UNAVAILABLE,
OasstErrorCode.TASK_REQUESTED_TYPE_NOT_AVAILABLE,
HTTPStatus.SERVICE_UNAVAILABLE,
)
if task_role != TaskRole.ANY:
# Todo: Allow role specific message selection...
raise OasstError(
f"No tasks of type '{desired_task_type.value}' are currently available.",
OasstErrorCode.TASK_REQUESTED_TYPE_UNAVAILABLE,
OasstErrorCode.TASK_REQUESTED_TYPE_NOT_AVAILABLE,
HTTPStatus.SERVICE_UNAVAILABLE,
)
message_tree_id = None