Close connection before and after executing periodic OCR task, to avoid stale DB connection remaining open. Ref: Issue #4

This commit is contained in:
Roberto Rosario
2014-05-22 16:44:48 -04:00
parent 60bdf37fbd
commit ee1e732776

View File

@@ -5,6 +5,7 @@ import platform
import logging
from django.db.models import Q
from django import db
from job_processor.api import process_job
from lock_manager import Lock, LockError
@@ -48,6 +49,8 @@ def task_process_queue_document(queue_document_id):
def task_process_document_queues():
# Make sure this task get a fresh connection to the database
db.close_connection()
logger.debug('executed')
# TODO: reset_orphans()
q_pending = Q(state=QUEUEDOCUMENT_STATE_PENDING)
@@ -74,3 +77,6 @@ def task_process_document_queues():
logger.debug('already processing maximum')
else:
logger.debug('nothing to process')
# Close the database explicitly or else Django keeps it open
db.close_connection()