示例#1
0
def check_deposit_task():
    
    from nextmng.common.importer import import_depot
    
    logger.info('Check deposit started')
    
    # The cache key consists of the task name and the MD5 digest
    # of the feed URL.
    lock_id = '{0}-lock'.format("check_deposit_task")

    # cache.add fails if if the key already exists
    acquire_lock = lambda: cache.add(lock_id, 'true', LOCK_EXPIRE)
    # memcache delete is very slow, but we have to use it to take
    # advantage of using add() for atomic locking
    release_lock = lambda: cache.delete(lock_id)
    
    _imported    = 0
    
    if acquire_lock():
        try:
            _imported = import_depot()
        finally:
            release_lock()
            logger.info('Check deposit is finished')
        return _imported

    logger.info('Check deposit is already running by another worker')
示例#2
0
 def handle_noargs(self, **opts):
 
     import_depot()