示例#1
0
    def delete(self, key, ignore_missing=False):
        with self._lock:
            try:
                subject = self._pool.pop(key)
            except KeyError:
                if not ignore_missing:
                    raise exc.ServiceLookupError(self, key) from None
                return

            try:
                self._delete(subject)
            except Exception as e:
                self._pool[key] = subject
                raise exc.ServiceDeleteError(self, key, subject) from e
示例#2
0
 def lookup(self, key):
     try:
         item = self._pool[key]
     except KeyError:
         raise exc.ServiceLookupError(self, key) from None
     return item