def __cleanup_timer(self): last_cleanup = rospy.Time.now() sleeptime = rospy.Duration(0.5) while not rospy.is_shutdown(): if rospy.get_param('~storage/auto_cleanup', True) and \ older_than(last_cleanup, rospy.Duration(rospy.get_param('~storage/cleanup_timer', 30))): # not rospy.Duration( # rospy.get_param('/arni/storage/cleanup_timer', 30)) > rospy.Time.now() - last_cleanup: last_cleanup = rospy.Time.now() self.__clean_up() rospy.sleep(sleeptime)
def __clean_up(self): """ Automatically removes all objects in the storage older than *duration*. """ counter = 0 for ident in self.storage.keys(): for stamp in self.storage[ident].keys(): if older_than(stamp, rospy.Duration(self.duration)): # if rospy.Time.now() - stamp > rospy.Duration(self.duration): del self.storage[ident][stamp] counter += 1 rospy.logdebug("[MetadataStorage] Cleared storage, removed %s packages." % counter)