How to use the apscheduler.schedulers.blocking.BlockingScheduler function in APScheduler

To help you get started, we’ve selected a few APScheduler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lonelyhentai / minellius / crawler / collect_data.py View on Github external
VALUES ('{k}','{dic}');"""
        common_log(f"insert {k}")
        try:
            # 执行sql语句
            cursor.execute(sql)
            # 执行sql语句
            connect.commit()
        except Exception as e:
            # 发生错误时回滚
            common_log(str(e))
            connect.rollback()
    connect.close()


if __name__ == "__main__":
    sched = BlockingScheduler()
    main()
    sched.add_job(main, 'interval', hours=24)
    sched.start()
github cogaplex-bts / bts / pytorch / run_bts_eval_schedule.py View on Github external
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see 

import os
import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler()

@scheduler.scheduled_job('interval', minutes=1, start_date=datetime.datetime.now() + datetime.timedelta(0,3))
def run_eval():
    command = 'export CUDA_VISIBLE_DEVICES=0; ' \
              '/usr/bin/python ' \
              'bts_eval.py ' \
              '--encoder densenet161_bts ' \
              '--dataset kitti ' \
              '--data_path ../../dataset/kitti_dataset/ ' \
              '--gt_path ../../dataset/kitti_dataset/data_depth_annotated/ ' \
              '--filenames_file ../train_test_inputs/eigen_test_files_with_gt.txt ' \
              '--input_height 352 ' \
              '--input_width 1216 ' \
              '--garg_crop ' \
              '--max_depth 80 ' \
              '--max_depth_eval 80 ' \
github mitshel / sopds / opds_catalog / management / commands / sopds_scanner.py View on Github external
def start(self):
        writepid(self.pidfile)
        self.stdout.write('Startup scheduled book-scan (min=%s, hour=%s, day_of_week=%s, day=%s).'%(SCAN_SHED_MIN,SCAN_SHED_HOUR,SCAN_SHED_DOW,SCAN_SHED_DAY))
        sched = BlockingScheduler()
        sched.add_job(self.scan, 'cron', day=SCAN_SHED_DAY, day_of_week=SCAN_SHED_DOW, hour=SCAN_SHED_HOUR, minute=SCAN_SHED_MIN)
        quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C'
        self.stdout.write("Quit the server with %s.\n"%quit_command)  
        try:
            sched.start()
        except (KeyboardInterrupt, SystemExit):
            pass
github keiffster / program-y / src / programy / scheduling / scheduler.py View on Github external
def _create_scheduler(self):
        if self._configuration is not None:
            config = self._configuration.create_scheduler_config()
            if self._configuration.blocking is True:
                if config is not None:
                    YLogger.debug(None, "Creating Blocking Scheduler WITH config")
                    return BlockingScheduler(config)
                else:
                    YLogger.debug(None, "Creating Blocking Scheduler WITHOUT config")
                    return BlockingScheduler()
            else:
                if config is not None:
                    YLogger.debug(None, "Creating Background Scheduler WITH config")
                    return BackgroundScheduler(config)

        YLogger.debug(None, "Creating Background Scheduler WITHOUT config")
        return BackgroundScheduler()
github NCI-GDC / gdcdatamodel / template / run.py View on Github external
#!/usr/bin/python

import logging

logging.basicConfig(level = logging.INFO, format = '%(asctime)s %(name)-6s %(levelname)-4s %(message)s' )
logger = logging.getLogger(name = "[{name}]".format(name = __name__))

from app.etl import ETL
from app import settings
from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()
sync = ETL()

@sched.scheduled_job('interval', **settings.get('interval', {'minutes': 5}))
def run():
    sync.run()

if __name__ == '__main__':
    sync.run()
    if settings.get('schedule', False): sched.start()
github mitshel / sopds / opds_catalog / management / commands / sopds_scanner.py View on Github external
def start(self):
        writepid(self.pidfile)
        self.SCAN_SHED_DAY = config.SOPDS_SCAN_SHED_DAY
        self.SCAN_SHED_DOW = config.SOPDS_SCAN_SHED_DOW
        self.SCAN_SHED_HOUR = config.SOPDS_SCAN_SHED_HOUR
        self.SCAN_SHED_MIN = config.SOPDS_SCAN_SHED_MIN
        self.stdout.write('Startup scheduled book-scan (min=%s, hour=%s, day_of_week=%s, day=%s).'%(self.SCAN_SHED_MIN,self.SCAN_SHED_HOUR,self.SCAN_SHED_DOW,self.SCAN_SHED_DAY))
        self.sched = BlockingScheduler()
        self.sched.add_job(self.scan, 'cron', day=self.SCAN_SHED_DAY, day_of_week=self.SCAN_SHED_DOW, hour=self.SCAN_SHED_HOUR, minute=self.SCAN_SHED_MIN, id='scan')
        self.sched.add_job(self.check_settings, 'cron', minute='*/10', id='check')
        quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C'
        self.stdout.write("Quit the server with %s.\n"%quit_command)  
        try:
            self.sched.start()
        except (KeyboardInterrupt, SystemExit):
            pass
github mobabel / wechat-group-ibot / ibot_gp_helper.py View on Github external
def start_schedule_for_analyzing():
    scheduler = BlockingScheduler()
    # 08:10am at the first day of the month
    scheduler.add_job(lambda: process_schedule(bot_db, bot, group_1), 'cron',
                      month='1-12', day=1, hour=8, minute=1, timezone="Europe/Paris")
    # local test
    if debug:
        # scheduler.add_job(lambda: process_schedule(bot_db, bot, group_1),
        # 'cron', hour=17, minute=31, timezone="Europe/Paris")
        scheduler.add_job(lambda: process_schedule(bot_db, bot, group_1), 'interval', minutes=2)

    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass
github ym2011 / PEST / Fuxi-Scanner / fuxi / views / modules / discovery / asset_discovery.py View on Github external
def task_schedule(self):
        scheduler = BlockingScheduler()
        try:
            scheduler.add_job(self._get_task, 'cron', day='1-31', hour=self.sche_time[0],
                              minute=self.sche_time[1], second=self.sche_time[2])
            scheduler.start()
        except Exception as e:
            print(e)
github mozilla / kitsune / scripts / cron.py View on Github external
from __future__ import print_function
import datetime
import os
import sys
from subprocess import check_call

from django.conf import settings

import babis
from apscheduler.schedulers.blocking import BlockingScheduler


MANAGE = os.path.join(settings.ROOT, 'manage.py')
schedule = BlockingScheduler()


def call_command(command):
    check_call('python {0} {1}'.format(MANAGE, command), shell=True)


class scheduled_job(object):
    """Decorator for scheduled jobs. Takes same args as apscheduler.schedule_job."""
    def __init__(self, *args, **kwargs):
        self.args = args
        self.kwargs = kwargs
        self.skip = self.kwargs.pop('skip', False)

    def __call__(self, fn):
        self.name = fn.__name__
        if self.skip:
github alphagov / notify-api / app / job / job_schedules.py View on Github external
from apscheduler.schedulers.blocking import BlockingScheduler
from app.job.sms_jobs import send_sms, fetch_sms_status
from app.job.email_jobs import send_email, fetch_email_status

sched = BlockingScheduler()


@sched.scheduled_job('interval', seconds=1)
def send_sms_schedule():
    # print("Running sending job Sending")
    sched.add_job(func=send_sms, max_instances=1, id="sms_sending_job")


@sched.scheduled_job('interval', minutes=5)
def send_sms_schedule():
    # print("Running status job")
    sched.add_job(func=fetch_sms_status, max_instances=1, id="sms_status_checking_job")


@sched.scheduled_job('interval', seconds=1)
def send_email_schedule():