def sync(self):
    self.log.debug('Inquiring about %s celery task(s)', len(self.tasks))
    for (key, task) in list(self.tasks.items()):
        try:
            state = task.state
            if (self.last_state[key] != state):
                if (state == celery_states.SUCCESS):
                    self.success(key)
                    del self.tasks[key]
                    del self.last_state[key]
                elif (state == celery_states.FAILURE):
                    self.fail(key)
                    del self.tasks[key]
                    del self.last_state[key]
                elif (state == celery_states.REVOKED):
                    self.fail(key)
                    del self.tasks[key]
                    del self.last_state[key]
                else:
                    self.log.info('Unexpected state: %s', state)
                    self.last_state[key] = state
        except Exception as e:
            self.log.error('Error syncing the celery executor, ignoring it:')
            self.log.exception(e)
def sync(self):
    self.log.debug('Inquiring about %s celery task(s)', len(self.tasks))
    for (key, task) in list(self.tasks.items()):
        try:
            state = task.state
            if (self.last_state[key] != state):
                if (state == celery_states.SUCCESS):
                    self.success(key)
                    del self.tasks[key]
                    del self.last_state[key]
                elif (state == celery_states.FAILURE):
                    self.fail(key)
                    del self.tasks[key]
                    del self.last_state[key]
                elif (state == celery_states.REVOKED):
                    self.fail(key)
                    del self.tasks[key]
                    del self.last_state[key]
                else:
                    self.log.info('Unexpected state: %s', state)
                    self.last_state[key] = state
        except Exception as e:
            self.log.error('Error syncing the celery executor, ignoring it:')
            self.log.exception(e)