Esempio n. 1
0
 def add(self, fxn, interval=SMALL_RUN_INTERVAL):
     """ add a function to the scheduler """
     msg = "registering function {0} with interval {1}"
     @wraps(fxn)
     def newf(*args, **kargs):
         if self.ask_stop:
             return
         else:
             return fxn(*args, **kargs)
     scheduler_log.info(msg.format(fxn, interval))
     self.scheduler.every(interval).seconds.do(newf)
Esempio n. 2
0
 def run_continuously(self):
     """ main loop for scheduler """
     count = 0
     while not self.ask_stop:
         if not get_smash():
             scheduler_log.info('smash not ready')
             continue
         count += 1
         time.sleep(WAIT_INTERVAL)
         if count >= REPORT_COUNT:
             scheduler_log.info(str(self))
             count = 0
         self.scheduler.run_pending()
     scheduler_log.info('scheduler stopping')
Esempio n. 3
0
 def scheduled_rescan(self):
     scheduler_log.info("running scheduled rescan")
     self.reload()
Esempio n. 4
0
 def scheduled_rehash(self):
     scheduler_log.info("scheduled rehash")
     self.shell.magics_manager.magics['line']['rehashx']()
Esempio n. 5
0
 def stop(self):
     """ stop the smash scheduler """
     scheduler_log.info("asking for stop")
     self.ask_stop = True
Esempio n. 6
0
 def start(self):
     """ stop the smash scheduler """
     thread = threading.Thread(target=self.run_continuously)
     thread.start()
     scheduler_log.info('scheduler started')
     return thread