Add plugable locking backend support. Add threadsafe file lock backend.

This commit is contained in:
Roberto Rosario
2016-11-13 03:50:09 -04:00
parent f5e3d5a8f2
commit 44531bd92a
12 changed files with 155 additions and 65 deletions

View File

@@ -5,6 +5,7 @@ import logging
from django.apps import apps
from lock_manager import LockError
from lock_manager.runtime import locking_backend
from mayan.celery import app
from .literals import CHECKOUT_EXPIRATION_LOCK_EXPIRE
@@ -17,15 +18,12 @@ def task_check_expired_check_outs():
DocumentCheckout = apps.get_model(
app_label='checkouts', model_name='DocumentCheckout'
)
Lock = apps.get_model(
app_label='lock_manager', model_name='Lock'
)
logger.debug('executing...')
lock_id = 'task_expired_check_outs'
try:
logger.debug('trying to acquire lock: %s', lock_id)
lock = Lock.objects.acquire_lock(
lock = locking_backend.acquire_lock(
name=lock_id, timeout=CHECKOUT_EXPIRATION_LOCK_EXPIRE
)
logger.debug('acquired lock: %s', lock_id)