diff --git a/mayan/apps/checkouts/__init__.py b/mayan/apps/checkouts/__init__.py index 93d5eb4d65..b30e266d7b 100644 --- a/mayan/apps/checkouts/__init__.py +++ b/mayan/apps/checkouts/__init__.py @@ -50,5 +50,6 @@ app.conf.CELERYBEAT_SCHEDULE.update({ 'check_expired_check_outs': { 'task': 'checkouts.tasks.task_check_expired_check_outs', 'schedule': timedelta(seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL), + 'options': {'queue': 'checkouts'} }, }) diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index e6bb57b3eb..02648cfa25 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -125,7 +125,8 @@ class Document(models.Model): else: document_version = DocumentVersion.objects.get(pk=version) document_file = document_save_to_temp_dir(document_version, document_version.checksum) - return convert(document_file, output_filepath=cache_file_path, page=page, transformations=transformations, mimetype=self.file_mimetype) + task = task_convert.apply_async(kwargs=dict(input_filepath=document_file, output_filepath=cache_file_path, page=page, transformations=transformations, mimetype=self.file_mimetype), queue='converter') + return task.get(timeout=CONVERTER_TASK_TIMEOUT) def get_valid_image(self, size=DISPLAY_SIZE, page=DEFAULT_PAGE_NUMBER, zoom=DEFAULT_ZOOM_LEVEL, rotation=DEFAULT_ROTATION, version=None): if not version: @@ -134,7 +135,7 @@ class Document(models.Model): logger.debug('image_cache_name: %s' % image_cache_name) - task = task_convert.delay(image_cache_name, cleanup_files=False, size=size, zoom=zoom, rotation=rotation) + task = task_convert.apply_async(kwargs=dict(input_filepath=image_cache_name, cleanup_files=False, size=size, zoom=zoom, rotation=rotation), queue='converter') return task.get(timeout=CONVERTER_TASK_TIMEOUT) def get_image(self, size=DISPLAY_SIZE, page=DEFAULT_PAGE_NUMBER, zoom=DEFAULT_ZOOM_LEVEL, rotation=DEFAULT_ROTATION, as_base64=False, version=None): diff --git a/mayan/apps/ocr/__init__.py b/mayan/apps/ocr/__init__.py index d2f6d9f8f6..9af0756a16 100644 --- a/mayan/apps/ocr/__init__.py +++ b/mayan/apps/ocr/__init__.py @@ -42,7 +42,7 @@ def document_post_save(sender, instance, **kwargs): logger.debug('instance: %s' % instance) if kwargs.get('created', False): if AUTOMATIC_OCR: - task_do_ocr(instance.document.pk) + task_do_ocr.apply_async(args=[instance.document.pk], queue='ocr') @receiver(post_migrate, dispatch_uid='create_default_queue') diff --git a/mayan/apps/ocr/views.py b/mayan/apps/ocr/views.py index 6a7a4f8c63..80a4f6a29e 100644 --- a/mayan/apps/ocr/views.py +++ b/mayan/apps/ocr/views.py @@ -120,7 +120,7 @@ def submit_document_to_queue(request, document, post_submit_redirect=None): This view is meant to be reusable """ - task_do_ocr.delay(document.pk) + task_do_ocr.apply_async(args=[document.pk], queue='ocr') messages.success(request, _(u'Document: %(document)s was added to the OCR queue.') % { 'document': document} )