Use different queues for the background tasks
This commit is contained in:
@@ -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'}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user