def __del__(self): """This method garbage collects the object this pointer is pointing to. By default, PySyft assumes that every object only has one pointer to it. Thus, if the pointer gets garbage collected, we want to automatically garbage collect the object being pointed to. """ if self.garbage_collect_data: for id_at_location, location in zip(self._ids_at_location, self._locations): self.owner.send_msg(ForceObjectDeleteMessage(id_at_location), location)
def __del__(self): """This method garbage collects the object this pointer is pointing to. By default, PySyft assumes that every object only has one pointer to it. Thus, if the pointer gets garbage collected, we want to automatically garbage collect the object being pointed to. """ # if .get() gets called on the pointer before this method is called, then # the remote object has already been removed. This results in an error on # this next line because self no longer has .owner. Thus, we need to check # first here and not try to call self.owner.anything if self doesn't have # .owner anymore. if hasattr(self, "owner") and self.garbage_collect_data: # attribute pointers are not in charge of GC if self.point_to_attr is None: self.owner.send_msg(ForceObjectDeleteMessage(self.id_at_location), self.location)
def garbage(self, object_id, location): """ Garbage manager which collects all the remote GC request and batch send them every "delay" seconds for every location. """ max_delay = self.object_store.garbage_delay max_size = self.object_store.trash_capacity trash = self.object_store.trash if location.id not in trash: trash[location.id] = (time.time(), []) trash[location.id][1].append(object_id) delay = time.time() - trash[location.id][0] current_size = len(trash[location.id][1]) if delay > max_delay or current_size > max_size: self.send_msg(ForceObjectDeleteMessage(trash[location.id][1]), location) trash[location.id] = (time.time(), [])