Merge pull request #7 from dx-tan/add_elements
Add: Exception on timeout
This commit is contained in:
commit
e440079e53
@ -19,7 +19,7 @@ from ..annotation.api import throw_on_failure
|
||||
from ..constant.common import allowed_p_type, ProcessType, REQUEST_ID, FOLDER_TYPE, \
|
||||
FolderFileType, TEMPLATE_ID, EntityStatus, standard_ocr_list, pdf_extensions, image_extensions, allowed_file_extensions
|
||||
from ..exception.exceptions import RequiredFieldException, InvalidException, NotFoundException, \
|
||||
PermissionDeniedException, LimitReachedException, LockedEntityException, FileContentInvalidException
|
||||
PermissionDeniedException, LimitReachedException, LockedEntityException, FileContentInvalidException, ServiceTimeoutException
|
||||
from ..models import SubscriptionRequest, UserProfile, SubscriptionRequestFile, OcrTemplate, Subscription
|
||||
from ..response.ReportSerializer import ReportSerializer
|
||||
from ..utils import FileUtils, ProcessUtil
|
||||
@ -284,7 +284,7 @@ class CtelViewSet(viewsets.ViewSet):
|
||||
continue
|
||||
|
||||
return Response(status=status.HTTP_200_OK, data=serializer.data[0])
|
||||
return JsonResponse(status=status.HTTP_504_GATEWAY_TIMEOUT, data={"status": "timeout",f"request_id": "{rq_id}"})
|
||||
raise ServiceTimeoutException(excArgs=f"{rq_id}")
|
||||
|
||||
|
||||
@extend_schema(request=None, responses=None, tags=['data'])
|
||||
|
@ -41,6 +41,11 @@ class ServiceUnavailableException(GeneralException):
|
||||
default_code = 5030
|
||||
default_detail = 'Service temporarily unavailable, try again later.'
|
||||
|
||||
class ServiceTimeoutException(GeneralException):
|
||||
status_code = 503
|
||||
default_code = 5031
|
||||
default_detail = 'Timeout waiting for the result, try again later.'
|
||||
detail_with_arg = '{}'
|
||||
|
||||
class LockedEntityException(GeneralException):
|
||||
status_code = status.HTTP_423_LOCKED
|
||||
|
Loading…
Reference in New Issue
Block a user