def warm(self, jittering_ratio=0.2):
        """Progressively load the previous snapshot during the day.

        Loading all the snapshots at once can takes a substantial amount of time. This method, if called
        periodically during the day will progressively load those snapshots one by one. Because many workers are
        going to use this method at the same time, we add a jittering to the period between load to avoid
        hammering the disk at the same time.
        """
        if self.snapshot_to_load == None:
            last_period = self.current_period - dt.timedelta(days=self.expiration-1)
            self.compute_refresh_period()
            self.snapshot_to_load = []
            base_filename = "%s/%s_%s_*.dat" % (self.snapshot_path, self.name, self.expiration)
            availables_snapshots = glob.glob(base_filename)
            for filename in availables_snapshots:
                snapshot_period = dt.datetime.strptime(filename.split('_')[-1].strip('.dat'), "%Y-%m-%d")
                if snapshot_period >= last_period:
                    self.snapshot_to_load.append(filename)
                    self.ready = False

        if self.snapshot_to_load and self._should_warm():
            filename = self.snapshot_to_load.pop()
            self._union_bf_from_file(filename)
            jittering = self.warm_period * (np.random.random()-0.5) * jittering_ratio
            self.next_snapshot_load = time.time() + self.warm_period + jittering
            if not self.snapshot_to_load:
                self.ready = True
def warm ( self , jittering_ratio = 0.2 ) : if self . snapshot_to_load == None : last_period = self . current_period - dt . timedelta ( days = self . expiration - 1 ) self . compute_refresh_period ( ) self . snapshot_to_load = [ ] base_filename = "%s/%s_%s_*.dat" % ( self . snapshot_path , self . name , self . expiration ) availables_snapshots = glob . glob ( base_filename ) for filename in availables_snapshots : snapshot_period = dt . datetime . strptime ( filename . split ( '_' ) [ - 1 ] . strip ( '.dat' ) , "%Y-%m-%d" ) if snapshot_period >= last_period : self . snapshot_to_load . append ( filename ) self . ready = False if self . snapshot_to_load and self . _should_warm ( ) : filename = self . snapshot_to_load . pop ( ) self . _union_bf_from_file ( filename ) jittering = self . warm_period * ( np . random . random ( ) - 0.5 ) * jittering_ratio self . next_snapshot_load = time . time ( ) + self . warm_period + jittering if not self . snapshot_to_load : self . ready = True
Progressively load the previous snapshot during the day.

        Loading all the snapshots at once can takes a substantial amount of time. This method, if called
        periodically during the day will progressively load those snapshots one by one. Because many workers are
        going to use this method at the same time, we add a jittering to the period between load to avoid
        hammering the disk at the same time.