def _refresh(self, session, stopping=False):
        '''Get this task's current state.

        This must be called under the registry's lock.  It updates
        the :attr:`finished` and :attr:`failed` flags and the
        :attr:`data` dictionary based on the current state in the
        registry.

        In the normal case, nothing will change and this function
        will return normally.  If it turns out that the work unit
        is already finished, the state of this object will change
        before :exc:`rejester.exceptions.LostLease` is raised.

        :param session: locked registry session
        :param stopping: don't raise if the work unit is finished
        :raises rejester.exceptions.LostLease: if this worker is
          no longer doing this work unit

        '''
        data = session.get(
            WORK_UNITS_ + self.work_spec_name + _FINISHED, self.key)
        if data is not None:
            self.finished = True
            self.data = data
            if not stopping:
                raise LostLease('work unit is already finished')
            return
        self.finished = False

        data = session.get(
            WORK_UNITS_ + self.work_spec_name + _FAILED, self.key)
        if data is not None:
            self.failed = True
            self.data = data
            if not stopping:
                raise LostLease('work unit has already failed')
            return
        self.failed = False

        # (You need a pretty specific sequence of events to get here)
        data = session.get(
            WORK_UNITS_ + self.work_spec_name + _BLOCKED, self.key)
        if data is not None:
            self.data = data
            raise LostLease('work unit now blocked by others')

        worker_id = session.get(
            WORK_UNITS_ + self.work_spec_name + '_locks', self.key)
        if worker_id != self.worker_id:
            raise LostLease('work unit claimed by %r', worker_id)

        # NB: We could check the priority here, but don't.
        # If at this point we're technically overtime but nobody
        # else has started doing work yet, since we're under the
        # global lock, we can get away with finishing whatever
        # transition we were going to try to do.
        data = session.get(
            WORK_UNITS_ + self.work_spec_name, self.key)
        if data is None:
            raise NoSuchWorkUnitError('work unit is gone')
        # Since we should still own the work unit, any changes
        # in data should be on our end; do not touch it

        return
def _refresh ( self , session , stopping = False ) : data = session . get ( WORK_UNITS_ + self . work_spec_name + _FINISHED , self . key ) if data is not None : self . finished = True self . data = data if not stopping : raise LostLease ( 'work unit is already finished' ) return self . finished = False data = session . get ( WORK_UNITS_ + self . work_spec_name + _FAILED , self . key ) if data is not None : self . failed = True self . data = data if not stopping : raise LostLease ( 'work unit has already failed' ) return self . failed = False data = session . get ( WORK_UNITS_ + self . work_spec_name + _BLOCKED , self . key ) if data is not None : self . data = data raise LostLease ( 'work unit now blocked by others' ) worker_id = session . get ( WORK_UNITS_ + self . work_spec_name + '_locks' , self . key ) if worker_id != self . worker_id : raise LostLease ( 'work unit claimed by %r' , worker_id ) data = session . get ( WORK_UNITS_ + self . work_spec_name , self . key ) if data is None : raise NoSuchWorkUnitError ( 'work unit is gone' ) return
Get this task's current state.

        This must be called under the registry's lock.  It updates
        the :attr:`finished` and :attr:`failed` flags and the
        :attr:`data` dictionary based on the current state in the
        registry.

        In the normal case, nothing will change and this function
        will return normally.  If it turns out that the work unit
        is already finished, the state of this object will change
        before :exc:`rejester.exceptions.LostLease` is raised.

        :param session: locked registry session
        :param stopping: don't raise if the work unit is finished
        :raises rejester.exceptions.LostLease: if this worker is
          no longer doing this work unit