27 lines
704 B
Python
27 lines
704 B
Python
from __future__ import unicode_literals
|
|
|
|
import logging
|
|
|
|
from lock_manager import Lock, LockError
|
|
from mayan.celery import app
|
|
|
|
from .models import DocumentCheckout
|
|
|
|
LOCK_EXPIRE = 50
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@app.task(ignore_result=True)
|
|
def task_check_expired_check_outs():
|
|
logger.debug('executing...')
|
|
lock_id = 'task_expired_check_outs'
|
|
try:
|
|
logger.debug('trying to acquire lock: %s', lock_id)
|
|
lock = Lock.acquire_lock(lock_id, LOCK_EXPIRE)
|
|
logger.debug('acquired lock: %s', lock_id)
|
|
DocumentCheckout.objects.check_in_expired_check_outs()
|
|
lock.release()
|
|
except LockError:
|
|
logger.debug('unable to obtain lock')
|
|
pass
|