<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _main_loop(self):
        '''
        Main loop for the stats collector
        '''
        while self.active:
            self.expire()
            if self.roll and self.is_expired():
                self.start_time = self.start_time + self.window
                self._set_key()
            self.purge_old()
            time.sleep(self.cycle_time)
        self._clean_up()