Python schedule.run_pending() Examples

The following are 30 code examples of schedule.run_pending(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module schedule , or try the search function .
Example #1
Source File: scheduler.py    From haipproxy with MIT License 7 votes vote down vote up
def schedule_with_delay(self):
        for task in self.tasks:
            interval = task.get('interval')
            schedule.every(interval).minutes.do(self.schedule_task_with_lock, task)
        while True:
            schedule.run_pending()
            time.sleep(1) 
Example #2
Source File: functions.py    From MalPipe with GNU General Public License v3.0 7 votes vote down vote up
def run():
	# Load all modules and print active list
	feeds = objects.Feeds()
	exporters = objects.Exporters()
	processors = objects.Processors()
	print "Active Modules:"
	feeds.print_list()
	processors.print_list()	
	exporters.print_list()

	print "\nStarting..."

	feeds.start()

	while True:
		try:
			schedule.run_pending()
		except Exception, e:
			print "Excepion running pending: %s" % (e)
		time.sleep(10) 
Example #3
Source File: daily_report.py    From selene-backend with GNU Affero General Public License v3.0 7 votes vote down vote up
def _run(self):
        if self.args.run_mode == 'job':
            schedule.every().day.at('00:00').do(self._build_report)
            while True:
                schedule.run_pending()
                time.sleep(1)
        else:
            self._build_report(self.args.date) 
Example #4
Source File: idx_server.py    From DarkDarkGo with MIT License 6 votes vote down vote up
def run_schedule():
    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #5
Source File: run.py    From baleen with MIT License 6 votes vote down vote up
def handle(self, args):
        logger = IngestLogger()
        logger.info(
            "Starting Baleen v{} ingestion service every hour.".format(baleen.get_version())
        )

        schedule.every().hour.do(partial(self.ingest, args))

        while True:
            try:
                schedule.run_pending()
                time.sleep(1)
            except (KeyboardInterrupt, SystemExit):
                logger.info("Graceful shutdown of Baleen ingestion service.")
                return ""
            except Exception as e:
                logger.critical(str(e))
                return str(e) 
Example #6
Source File: jobs.py    From sensu_drive with MIT License 6 votes vote down vote up
def handle(self, *args, **kwargs):

        logger.info("%s - starting jobs schedule" % (__name__))
            
        try:
            '''            
            schedule.every().hour.do(job_update_entities)
            schedule.every().hour.do(job_update_clients)
            schedule.every().hour.do(job_update_checks)
            schedule.every().hour.do(job_update_trends)
            #schedule.every(10).minutes.do(job_update_events)
            '''
            
            schedule.every(settings.CACHE_ENTITY_TTL).seconds.do(job_update_entities)
            schedule.every(settings.CACHE_CLIENT_TTL).seconds.do(job_update_clients)
            schedule.every(settings.CACHE_TRENDS_TTL).seconds.do(job_update_trends)
            
            
            while True:
                schedule.run_pending()
                sleep(1)

        except KeyboardInterrupt:
            logger.info("%s - user signal exit!" % (__name__))
            exit(0) 
Example #7
Source File: scheduler.py    From ab-2018 with GNU General Public License v3.0 6 votes vote down vote up
def run_continuously(self, interval=1):
        """
        https://raw.githubusercontent.com/mrhwick/schedule/master/schedule/__init__.py
        """
        print("Started to run continuously")
        cease_continuous_run = Event()

        class ScheduleThread(Thread):
            @classmethod
            def run(cls):
                while not cease_continuous_run.is_set():
                    schedule.run_pending()
                    time.sleep(interval)

        continuous_thread = ScheduleThread()
        continuous_thread.start()
        return cease_continuous_run 
Example #8
Source File: bot.py    From firefly-iii-telegram-bot with GNU General Public License v3.0 6 votes vote down vote up
def __non_threaded_polling(self, schedule, none_stop=False, interval=0, timeout=3):
        logger.info('Started polling.')
        self._TeleBot__stop_polling.clear()
        error_interval = .25

        while not self._TeleBot__stop_polling.wait(interval):
            try:
                schedule.run_pending()
                self._TeleBot__retrieve_updates(timeout)
                error_interval = .25
            except apihelper.ApiException as e:
                logger.error(e)
                if not none_stop:
                    self._TeleBot__stop_polling.set()
                    logger.info("Exception occurred. Stopping.")
                else:
                    logger.info("Waiting for {0} seconds until retry".format(error_interval))
                    time.sleep(error_interval)
                    error_interval *= 2
            except KeyboardInterrupt:
                logger.info("KeyboardInterrupt received.")
                self._TeleBot__stop_polling.set()
                break

        logger.info('Stopped polling.') 
Example #9
Source File: smart_module.py    From hapi with GNU General Public License v3.0 6 votes vote down vote up
def main():
    try:
        smart_module = SmartModule()
        smart_module.asset.load_asset_info()
        smart_module.load_site_data()
        smart_module.discover()
        smart_module.load_influx_settings()
    except Exception as excpt:
        Log.exception("Error initializing Smart Module. %s.", excpt)

    while 1:
        try:
            time.sleep(0.5)
            schedule.run_pending()
        except Exception as excpt:
            Log.exception("Error in Smart Module main loop. %s.", excpt)
            break 
Example #10
Source File: convert.py    From fogernetes with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def schedule_main():
    print "Convert directory: %s" % config.UPLOADED_FILES_DEST
    convert()
    schedule.every(5).minutes.do(convert)
    while True:
        # print "."
        schedule.run_pending()
        time.sleep(1) 
Example #11
Source File: api.py    From friartuck with MIT License 5 votes vote down vote up
def run_scheduler(self, name):
        self.engine_running = True
        log.info("**** running - %s" % name)
        while 1:
            schedule.run_pending()
            time.sleep(1)
            if self.stop_engine:
                break
        self.engine_running = False
        log.info("**** exiting - %s" % name) 
Example #12
Source File: Scheduler.py    From hogar with MIT License 5 votes vote down vote up
def scheduler_init (parent):
    '''
        Schedule Init

        Start the main loop for the internal scheduler that
        ticks every second.

        --
        @param  parent:int  The PID of the parent.

        @return void
    '''

    # Define the jobs to run at which intervals
    schedule.every().minute.do(Reminder.run_remind_once)
    schedule.every().minute.do(Reminder.run_remind_recurring)

    # Start the main thread, polling the schedules
    # every second
    while True:

        # Check if the current parent pid matches the original
        # parent that started us. If not, we should end.
        if os.getppid() != parent:
            logger.error(
                'Killing scheduler as it has become detached from parent PID.')

            sys.exit(1)

        # Run the schedule
        schedule.run_pending()
        time.sleep(1)

    return 
Example #13
Source File: sched.py    From ab-2018 with GNU General Public License v3.0 5 votes vote down vote up
def allektamovikmovik():
        while True:
                schedule.run_pending()
                time.sleep(1) 
Example #14
Source File: cron.py    From coriolis with GNU Affero General Public License v3.0 5 votes vote down vote up
def _loop(self):
        while True:
            schedule.run_pending()
            time.sleep(.2) 
Example #15
Source File: thermostat.py    From thermostat with MIT License 5 votes vote down vote up
def startScheduler():
	log( LOG_LEVEL_INFO, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_TEXT, "Started" )
	while True:
		if holdControl.state == "normal":
			with scheduleLock:
				log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_TEXT, "Running pending" )
				schedule.run_pending()

		time.sleep( 10 ) 
Example #16
Source File: main.py    From poseidon with Apache License 2.0 5 votes vote down vote up
def schedule_thread_worker(schedule):
    ''' schedule thread, takes care of running processes in the future '''
    global CTRL_C
    logger.debug('Starting thread_worker')
    while not CTRL_C['STOP']:
        sys.stdout.flush()
        schedule.run_pending()
        time.sleep(1)
    logger.debug('Threading stop:{0}'.format(
        threading.current_thread().getName()))
    sys.exit() 
Example #17
Source File: CTPFileTradeTool.py    From ParadoxTrading with MIT License 5 votes vote down vote up
def run(self):
        schedule.every().day.at("21:00").do(self.tradeFunc)
        schedule.every().day.at("09:00").do(self.tradeFunc)

        while True:
            schedule.run_pending()
            logging.info('WAIT {} sec'.format(schedule.idle_seconds()))
            sleep(max(schedule.idle_seconds(), 1)) 
Example #18
Source File: CTPDailyMarketTool.py    From ParadoxTrading with MIT License 5 votes vote down vote up
def run(self):
        schedule.every().day.at("14:55").do(self.marketFunc)

        while True:
            schedule.run_pending()
            logging.info('WAIT {} sec'.format(schedule.idle_seconds()))
            time.sleep(max(schedule.idle_seconds(), 1)) 
Example #19
Source File: scheduled_task.py    From hproxy with MIT License 5 votes vote down vote up
def refresh_task(ver_interval, spider_interval):
    schedule.every(ver_interval).minutes.do(refresh_proxy)
    schedule.every(spider_interval).minutes.do(crawl_proxy)

    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #20
Source File: main.py    From tls-canary with Mozilla Public License 2.0 5 votes vote down vote up
def run(output_directory: str) -> int:
        tlscanary_binary = "tlscanary"

        output_directory = os.path.abspath(output_directory)
        logger.info("Output directory is `%s`" % output_directory)

        symantec = SymantecJob(tlscanary_binary, os.path.join(output_directory))
        tlsdeprecation = TLSDeprecationJob(tlscanary_binary, os.path.join(output_directory))
        srcupdate = SrcUpdateJob(tlscanary_binary)

        # ####################################################################
        # Here's the the actual schedule #####################################
        # ####################################################################
        schedule.every(60).minutes.do(Scheduler.log_alive)
        schedule.every().monday.at("00:00").do(symantec.run)
        schedule.every().wednesday.at("00:00").do(tlsdeprecation.run)
        schedule.every().saturday.at("00:00").do(srcupdate.run)

        try:
            while True:
                schedule.run_pending()
                time.sleep(1)

        except KeyboardInterrupt:
            logger.critical("\nUser interrupt. Quitting...")
            return 10 
Example #21
Source File: scheduled_task.py    From owllook with Apache License 2.0 5 votes vote down vote up
def refresh_task():
    schedule.every(CONFIG.SCHEDULED_DICT['SPIDER_INTERVAL']).minutes.do(start_spider)
    # schedule.every(CONFIG.SCHEDULED_DICT['NOVELS_INTERVAL']).minutes.do(update_all_books_schedule)

    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #22
Source File: daily_report.py    From archon with MIT License 5 votes vote down vote up
def schedule_tasks():
    get_module_logger(__name__).info("schedule report")    
    log.info("schedule report")
    schedule.every(60*4).minutes.do(run_balance_report)    
    #schedule.every().day.at("10:30").do(run_balance_report)
    while True:
        schedule.run_pending()
        time.sleep(1)
    
    #schedule.every().hour.do(job) 
Example #23
Source File: run_job_put_tasks_weixin.py    From news_spider with MIT License 5 votes vote down vote up
def run():
    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #24
Source File: scheduler.py    From haipproxy with MIT License 5 votes vote down vote up
def squid_conf_update(usage, interval):
    """Timertask for updating proxies for squid config file"""
    # client_logger.info('the updating task is starting...')
    client = SquidClient(usage)
    client.update_conf()
    schedule.every(interval).minutes.do(client.update_conf)
    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #25
Source File: vlcscheduler.py    From VLC-Scheduler with MIT License 5 votes vote down vote up
def schedule_coro():
    while True:
        schedule.run_pending()
        await asyncio.sleep(1) 
Example #26
Source File: xuexi.py    From autoxuexi with GNU General Public License v3.0 5 votes vote down vote up
def run_monitor(self):
        self.__monitor_flag.set()
        while self.__monitor_flag.isSet():
            schedule.run_pending()
            time.sleep(1)
            # self.__monitor_flag.wait()
            if schedule.next_run is not None:
                self.auto_status.set(u'运行中...\n下次运行时间:\n %s\n当前时间:\n %s' % (schedule.next_run(), datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
            else:
                self.auto_status.set(u'状态:无任务')

        self.auto_status.set(u'状态:停止') 
Example #27
Source File: main.py    From dnsrobocert with MIT License 5 votes vote down vote up
def _watch_config(config_path: str, directory_path: str):
    LOGGER.info("Starting DNSroboCert.")

    with tempfile.TemporaryDirectory() as workspace:
        runtime_config_path = os.path.join(workspace, "dnsrobocert-runtime.yml")

        schedule.every().day.at("12:00").do(
            _renew_job, config_path=runtime_config_path, directory_path=directory_path
        )
        schedule.every().day.at("00:00").do(
            _renew_job, config_path=runtime_config_path, directory_path=directory_path
        )

        daemon = _Daemon()
        previous_digest = ""
        while not daemon.do_shutdown():
            schedule.run_pending()

            try:
                generated_config_path = legacy.migrate(config_path)
                effective_config_path = (
                    generated_config_path if generated_config_path else config_path
                )
                digest = utils.digest(effective_config_path)

                if digest != previous_digest:
                    previous_digest = digest
                    _process_config(
                        effective_config_path, directory_path, runtime_config_path
                    )
            except BaseException as error:
                LOGGER.error("An error occurred during DNSroboCert watch:")
                LOGGER.error(error)
                traceback.print_exc(file=sys.stderr)

            time.sleep(1)

    LOGGER.info("Exiting DNSroboCert.") 
Example #28
Source File: PyWhatsapp.py    From PyWhatsapp with Apache License 2.0 5 votes vote down vote up
def scheduler():
    while True:
        schedule.run_pending()
        time.sleep(1) 
Example #29
Source File: controller.py    From GaragePi with MIT License 5 votes vote down vote up
def run_schedule(self):
        while 1:
            schedule.run_pending()
            time.sleep(1) 
Example #30
Source File: scheduler.py    From PyTrendFollow with MIT License 5 votes vote down vote up
def main():
    # width = pd.util.terminal.get_terminal_size() # find the width of the user's terminal window
    # rows, columns = os.popen('stty size', 'r').read().split()
    # pd.set_option('display.width', width[0]) # set that as the max width in Pandas
    # pd.set_option('display.width', int(columns)) # set that as the max width in Pandas

    set_schedule(config.strategy.portfolio_sync_time)

    if "--now" in sys.argv:
        sync_trades()

    if "--quit" not in sys.argv:
        while True:
            schedule.run_pending()
            sleep(1)