Esempio n. 1
0
    def host_acquire_lock(self, request):

        try:
            host = request[0]
        except IndexError:
            raise ValueError('Host is required')

        check_host(host)

        lock_id = self.HOST_LOCK.format(host)
        sync_manager.persistent_locks_acquire([lock_id])

        return lock_id
Esempio n. 2
0
    def host_acquire_lock(self, request):

        try:
            host = request[0]
        except IndexError:
            raise ValueError('Host is required')

        check_host(host)

        lock_id = self.HOST_LOCK.format(host)
        sync_manager.persistent_locks_acquire([lock_id])

        return lock_id
Esempio n. 3
0
    def perform_locks(self):
        try:
            sync_manager.persistent_locks_acquire(self._locks, self.id)
        except LockAlreadyAcquiredError as e:
            if e.holder_id != self.id:
                logger.error('Job {0}: {1} is already '
                    'being processed by job {2}'.format(self.id, e.lock_id, e.holder_id))

                last_error = self.error_msg and self.error_msg[-1] or None
                if last_error and (last_error.get('code') != API_ERROR_CODE.LOCK_ALREADY_ACQUIRED or
                                   last_error.get('holder_id') != e.holder_id):
                    self.add_error(e)

                raise
            else:
                logger.warn('Job {0}: lock for group {1} has already '
                    'been acquired, skipping'.format(self.id, self.group))
Esempio n. 4
0
    def perform_locks(self):
        try:
            sync_manager.persistent_locks_acquire(self._locks, self.id)
        except LockAlreadyAcquiredError as e:
            if e.holder_id != self.id:
                logger.error('Job {0}: {1} is already '
                             'being processed by job {2}'.format(
                                 self.id, e.lock_id, e.holder_id))

                last_error = self.error_msg and self.error_msg[-1] or None
                if last_error and (last_error.get('code') !=
                                   API_ERROR_CODE.LOCK_ALREADY_ACQUIRED or
                                   last_error.get('holder_id') != e.holder_id):
                    self.add_error(e)

                raise
            else:
                logger.warn('Job {0}: lock for group {1} has already '
                            'been acquired, skipping'.format(
                                self.id, self.group))