From 1ffba7e40f91904907bac1440cfb23650e455e24 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 13 Jan 2015 02:56:13 -0400 Subject: [PATCH] Increase preview task timeout to 60 seconds to cover for even the wost load scenario. Consolidate literal to store the timeout value. --- mayan/apps/documents/api_views.py | 4 +--- mayan/apps/documents/literals.py | 2 ++ mayan/apps/documents/views.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mayan/apps/documents/api_views.py b/mayan/apps/documents/api_views.py index 8579399a2a..3a7a58cb25 100644 --- a/mayan/apps/documents/api_views.py +++ b/mayan/apps/documents/api_views.py @@ -18,6 +18,7 @@ from permissions.models import Permission from rest_api.filters import MayanObjectPermissionsFilter from rest_api.permissions import MayanPermission +from .literals import DOCUMENT_IMAGE_TASK_TIMEOUT from .models import (Document, DocumentPage, DocumentType, DocumentVersion, RecentDocument) from .permissions import (PERMISSION_DOCUMENT_CREATE, @@ -37,9 +38,6 @@ from .settings import DISPLAY_SIZE, ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL from .tasks import task_get_document_image, task_new_document -DOCUMENT_IMAGE_TASK_TIMEOUT = 10 - - class APIDocumentListView(generics.ListAPIView): """ Returns a list of all the documents. diff --git a/mayan/apps/documents/literals.py b/mayan/apps/documents/literals.py index 1bec3f53bd..bc8d5eee50 100644 --- a/mayan/apps/documents/literals.py +++ b/mayan/apps/documents/literals.py @@ -8,3 +8,5 @@ PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png' DEFAULT_ZIP_FILENAME = u'document_bundle.zip' LANGUAGE_CHOICES = [(i.bibliographic, i.name) for i in list(pycountry.languages)] + +DOCUMENT_IMAGE_TASK_TIMEOUT = 20 diff --git a/mayan/apps/documents/views.py b/mayan/apps/documents/views.py index 0f64cb3c40..7e5d854bd6 100644 --- a/mayan/apps/documents/views.py +++ b/mayan/apps/documents/views.py @@ -34,6 +34,7 @@ from .forms import (DocumentContentForm, DocumentDownloadForm, DocumentForm, DocumentTypeForm, DocumentTypeFilenameForm, DocumentTypeFilenameForm_create, DocumentTypeSelectForm, PrintForm) +from .literals import DOCUMENT_IMAGE_TASK_TIMEOUT from .models import (Document, DocumentType, DocumentPage, DocumentPageTransformation, DocumentTypeFilename, DocumentVersion, RecentDocument) @@ -333,7 +334,7 @@ def get_document_image(request, document_id, size=PREVIEW_SIZE): rotation = int(request.GET.get('rotation', DEFAULT_ROTATION)) % 360 task = task_get_document_image.apply_async(kwargs=dict(document_id=document.pk, size=size, page=page, zoom=zoom, rotation=rotation, as_base64=False, version=version), queue='converter') - return sendfile.sendfile(request, task.get(timeout=10), mimetype=DEFAULT_FILE_FORMAT_MIMETYPE) + return sendfile.sendfile(request, task.get(timeout=DOCUMENT_IMAGE_TASK_TIMEOUT), mimetype=DEFAULT_FILE_FORMAT_MIMETYPE) def document_download(request, document_id=None, document_id_list=None, document_version_pk=None):