Made the queue processing interval configurable by means of a new setting: OCR_QUEUE_PROCESSING_INTERVAL
This commit is contained in:
@@ -7,3 +7,4 @@ REPLICATION_DELAY = getattr(settings, 'OCR_REPLICATION_DELAY', 10) # In seconds
|
|||||||
NODE_CONCURRENT_EXECUTION = getattr(settings, 'OCR_NODE_CONCURRENT_EXECUTION', 1)
|
NODE_CONCURRENT_EXECUTION = getattr(settings, 'OCR_NODE_CONCURRENT_EXECUTION', 1)
|
||||||
AUTOMATIC_OCR = getattr(settings, 'OCR_AUTOMATIC_OCR', False)
|
AUTOMATIC_OCR = getattr(settings, 'OCR_AUTOMATIC_OCR', False)
|
||||||
PDFTOTEXT_PATH = getattr(settings, 'OCR_PDFTOTEXT_PATH', u'/usr/bin/pdftotext')
|
PDFTOTEXT_PATH = getattr(settings, 'OCR_PDFTOTEXT_PATH', u'/usr/bin/pdftotext')
|
||||||
|
QUEUE_PROCESSING_INTERVAL = getattr(settings, 'OCR_QUEUE_PROCESSING_INTERVAL', 10) # In seconds
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import time
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from celery.decorators import task, periodic_task
|
from celery.decorators import task, periodic_task
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ from ocr.literals import QUEUEDOCUMENT_STATE_PENDING, \
|
|||||||
from ocr.models import QueueDocument, DocumentQueue
|
from ocr.models import QueueDocument, DocumentQueue
|
||||||
from ocr.conf.settings import NODE_CONCURRENT_EXECUTION
|
from ocr.conf.settings import NODE_CONCURRENT_EXECUTION
|
||||||
from ocr.conf.settings import REPLICATION_DELAY
|
from ocr.conf.settings import REPLICATION_DELAY
|
||||||
|
from ocr.conf.settings import QUEUE_PROCESSING_INTERVAL
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
@@ -24,6 +26,7 @@ def task_process_queue_document(queue_document_id):
|
|||||||
return
|
return
|
||||||
queue_document.state = QUEUEDOCUMENT_STATE_PROCESSING
|
queue_document.state = QUEUEDOCUMENT_STATE_PROCESSING
|
||||||
queue_document.node_name = platform.node()
|
queue_document.node_name = platform.node()
|
||||||
|
queue_document.result = task_process_queue_document.request.id
|
||||||
queue_document.save()
|
queue_document.save()
|
||||||
try:
|
try:
|
||||||
do_document_ocr(queue_document.document)
|
do_document_ocr(queue_document.document)
|
||||||
@@ -34,7 +37,7 @@ def task_process_queue_document(queue_document_id):
|
|||||||
queue_document.save()
|
queue_document.save()
|
||||||
|
|
||||||
|
|
||||||
@periodic_task(run_every=timedelta(seconds=15))
|
@periodic_task(run_every=timedelta(seconds=QUEUE_PROCESSING_INTERVAL))
|
||||||
def task_process_document_queues():
|
def task_process_document_queues():
|
||||||
#Introduce random 0 < t < 1 second delay to further reduce the
|
#Introduce random 0 < t < 1 second delay to further reduce the
|
||||||
#chance of a race condition
|
#chance of a race condition
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#OCR_REPLICATION_DELAY = 10
|
#OCR_REPLICATION_DELAY = 10
|
||||||
#OCR_AUTOMATIC_OCR = False
|
#OCR_AUTOMATIC_OCR = False
|
||||||
#OCR_PDFTOTEXT_PATH = u'/usr/bin/pdftotext'
|
#OCR_PDFTOTEXT_PATH = u'/usr/bin/pdftotext'
|
||||||
|
#OCR_QUEUE_PROCESSING_INTERVAL = 10 # In seconds
|
||||||
|
|
||||||
# Permissions
|
# Permissions
|
||||||
#ROLES_DEFAULT_ROLES = []
|
#ROLES_DEFAULT_ROLES = []
|
||||||
|
|||||||
Reference in New Issue
Block a user