Пример #1
0
 def is_object_none(self, msg):
     obj_id = msg.object_id
     if obj_id not in self.object_store._objects:
         # If the object is not present on the worker, raise an error
         raise ObjectNotFoundError(obj_id, self)
     obj = self.get_obj(msg.object_id)
     return obj is None
Пример #2
0
 def _get_obj(self, obj_id: Union[str, int]) -> object:
     try:
         obj = self._objects[obj_id]
     except KeyError as e:
         if obj_id not in self._objects:
             # Try to recover object on database
             obj = redis_db.hget(self.id, obj_id)
             if obj:
                 self._objects[obj_id] = deserialize(obj)
             else:
                 raise ObjectNotFoundError(obj_id, self)
         else:
             raise e
     return obj
Пример #3
0
    def get_obj(self, obj_id: Union[str, int]) -> object:
        """Returns the object from registry.

        Look up an object from the registry using its ID.

        Args:
            obj_id: A string or integer id of an object to look up.

        Returns:
            Object with id equals to `obj_id`.
        """

        try:
            obj = self._objects[obj_id]
        except KeyError as e:
            if obj_id not in self._objects:
                raise ObjectNotFoundError(obj_id, self)
            else:
                raise e

        return obj