def __init__(self, *args, **kwargs): self.region_name = cfg.CONF.region_name self.gclient = client.get_client() self.master_api = master.API() self.ctxt = context.get_admin_context() self.notifier = notifier.NotifierService( cfg.CONF.checker.notifier_level) job_defaults = { 'misfire_grace_time': 604800, 'coalesce': False, 'max_instances': 24, } self.apsched = background.BackgroundScheduler( job_defaults=job_defaults, timezone=pytz.utc) self.RESOURCE_LIST_METHOD = services.RESOURCE_LIST_METHOD self.DELETE_METHOD_MAP = services.DELETE_METHOD_MAP self.STOP_METHOD_MAP = services.STOP_METHOD_MAP self.RESOURCE_STOPPED_STATE = services.RESOURCE_STOPPED_STATE self.RESOURCE_GET_MAP = services.RESOURCE_GET_MAP # NOTE(suo): Import 'common' to invoke register_class methods. # Don't import this in module level, because it need to read # config file, so it should be imported after service initialization from gringotts.checker import common # noqa self.RESOURCE_CREATE_MAP = services.RESOURCE_CREATE_MAP super(CheckerService, self).__init__(*args, **kwargs)
def __init__(self, plugins: Iterable[PluginConfig] = None, max_workers: Optional[int] = None) -> None: """Initializer. This may be extended by each bot implementation to do some extra setup, but should not be overridden. For the term "extend" and "override," refer to pep257. :param plugins: List of plugin modules to import :param max_workers: Optional number of worker threads. Methods with @concurrent decorator will be submitted to this thread pool. """ if not plugins: plugins = () # {module_name: config, ...} # Some simple plugins can be used without configuration, so second # element may be omitted on assignment. # In that case, just give empty dictionary as configuration value. self.plugin_config = OrderedDict([(p[0], p[1] if len(p) > 1 else {}) for p in plugins]) self.max_workers = max_workers self.scheduler = background.BackgroundScheduler() self.user_context_map = {} # type: Dict[str, UserContext] # To be set on run() self.worker = None # type: ThreadPoolExecutor self.message_worker = None # type: ThreadExecutor cls = self.__class__ cls_name = cls.__name__ # Reset to ease tests in one file cls.__commands[cls_name] = [] cls.__schedules[cls_name] = [] # To refer to this instance from class method decorator cls.__instances[cls_name] = self
def __init__(self, dialog): self.label_17 = QtWidgets.QLabel(dialog) self.label_16 = QtWidgets.QLabel(dialog) self.label_15 = QtWidgets.QLabel(dialog) self.label_14 = QtWidgets.QLabel(dialog) self.label_13 = QtWidgets.QLabel(dialog) self.label_12 = QtWidgets.QLabel(dialog) self.label_11 = QtWidgets.QLabel(dialog) self.label_10 = QtWidgets.QLabel(dialog) self.label_9 = QtWidgets.QLabel(dialog) self.label_4 = QtWidgets.QLabel(dialog) self.label_8 = QtWidgets.QLabel(dialog) self.label_7 = QtWidgets.QLabel(dialog) self.label_6 = QtWidgets.QLabel(dialog) self.label_5 = QtWidgets.QLabel(dialog) self.label_3 = QtWidgets.QLabel(dialog) self.label_2 = QtWidgets.QLabel(dialog) self.label = QtWidgets.QLabel(dialog) self.interparkStart_btn = QtWidgets.QPushButton(dialog) self.pushButton_2 = QtWidgets.QPushButton(dialog) self.goodsCode_txt = QtWidgets.QLineEdit(dialog) self.yyyy_txt = QtWidgets.QLineEdit(dialog) self.MM_txt = QtWidgets.QLineEdit(dialog) self.dd_txt = QtWidgets.QLineEdit(dialog) self.hh_txt = QtWidgets.QLineEdit(dialog) self.mm_txt = QtWidgets.QLineEdit(dialog) self.zone_txt = QtWidgets.QLineEdit(dialog) self.seat_txt = QtWidgets.QLineEdit(dialog) self.ticketCount_txt = QtWidgets.QLineEdit(dialog) self.re_hh_txt = QtWidgets.QLineEdit(dialog) self.re_mm_txt = QtWidgets.QLineEdit(dialog) self.pw_txt = QtWidgets.QLineEdit(dialog) self.id_txt = QtWidgets.QLineEdit(dialog) self.tikecting_btn1 = QtWidgets.QPushButton(dialog) self.tikecting_btn2 = QtWidgets.QPushButton(dialog) self.reservationStart_btn = QtWidgets.QPushButton(dialog) self.reservatoin_stop_btn = QtWidgets.QPushButton(dialog) self.tk = TK.TK() self.while_check = True self.sched = b.BackgroundScheduler()
def __init__(self, apiclient, interval, job_path): # config_manager self.client = apiclient self.freezerc_executable = spawn.find_executable('freezer-agent') if self.freezerc_executable is None: # Needed in the case of a non-activated virtualenv self.freezerc_executable = spawn.find_executable('freezer-agent', path=':'.join( sys.path)) LOG.debug('Freezer-agent found at {0}'.format( self.freezerc_executable)) self.job_path = job_path self._client = None self.lock = threading.Lock() self.execution_lock = threading.Lock() job_defaults = {'coalesce': True, 'max_instances': 2} executors = { 'default': { 'type': 'threadpool', 'max_workers': 1 }, 'threadpool': { 'type': 'threadpool', 'max_workers': 10 } } self.scheduler = background.BackgroundScheduler( job_defaults=job_defaults, executors=executors) if self.client: self.scheduler.add_job(self.poll, 'interval', seconds=interval, id='api_poll', executor='default') self.add_job = self.scheduler.add_job self.remove_job = self.scheduler.remove_job self.jobs = {}
def __init__(self, *args, **kwargs): kwargs.update( host=cfg.CONF.host, topic=cfg.CONF.master.master_topic, ) self.locks = {} self.gclient = client.get_client() self.ctxt = context.get_admin_context() job_defaults = { 'misfire_grace_time': 6048000, 'coalesce': False, 'max_instances': 24, } self.apsched = background.BackgroundScheduler( job_defaults=job_defaults, timezone=pytz.utc) self.DELETE_METHOD_MAP = services.DELETE_METHOD_MAP self.STOP_METHOD_MAP = services.STOP_METHOD_MAP self.RESOURCE_GET_MAP = services.RESOURCE_GET_MAP super(MasterService, self).__init__(*args, **kwargs)
import logging from datetime import datetime import requests from apscheduler.schedulers import background import atexit from dollar.ml.fill_database import fill_database from dollar.settings import MARKETPLACE_URL log = logging.getLogger(__name__) def fetch(): log.debug('started fetch') data = requests.get(MARKETPLACE_URL + 'api/get-data').json() fill_database(data['companies'], data['orders'], data['products']) def request_fetch_now(): interval_fetch.reschedule('interval', minutes=30) interval_fetch.modify(next_run_time=datetime.now()) fetchScheduler = background.BackgroundScheduler() interval_fetch = fetchScheduler.add_job(fetch, 'interval', days=1) # request_fetch_now() atexit.register(lambda: fetchScheduler.shutdown(wait=False))
def scheduler(self): if self._scheduler is None: self._scheduler = background.BackgroundScheduler() return self._scheduler
raise ValueError('list_only conflicts with serial port arguments') # open serial port if not print_only: device = serial.Serial(serial_port, 115200, timeout=1) print('🔌Successfully open serial port', device.name) # init increses variable # get_price_change() # print('Initialized cryptocurrency price changes:') # for item in price_change: # print(item, price_change[item]) # create a schedular to get price change percent print('💹 Creating price change update schedular') schedular = background.BackgroundScheduler() schedular.add_job(get_price_change, 'interval', seconds=2, id='refresh_price_change') print('🌐 Creating global ETH mining status update schedular') schedular.add_job(update_network_status, 'interval', hours=24, id='refresh_eth') # create another schedular to update mining pool status if pool: print('⭐ Creating sparkpool update schedular') schedular.add_job(update_pool_status,
def timertask(): """ Scheduled tasks summary :return:None """ try: scheduler = background.BackgroundScheduler( job_defaults={'max_instances': 200}) # Add tasks # Warehouse, organization, and owner correspondence timing task scheduler.add_job(taskcontroller.gwcontroller, 'cron', day_of_week='0-6', hour=0, minute=2) # Manual CVE data entry timing task scheduler.add_job(taskcontroller.runtabletask, 'interval', minutes=40) # Error data export and email sending timing task scheduler.add_job(taskcontroller.toexcelcontroller, 'cron', day_of_week='0-6', hour=7, minute=30) # Package name correspondence relationship timing task scheduler.add_job(taskcontroller.runmappeingtask, 'cron', day_of_week='0-6', hour=7, minute=30) # Delete ,iles timed tasks that are more than one month old scheduler.add_job(taskcontroller.rundelfiletask, 'cron', day_of_week='0-6', hour=9, minute=30) # issue record email feedback scheduler.add_job(taskcontroller.run_issue_record_task, 'cron', day_of_week='0-6', hour=7, minute=30) # analysis the table package whitelist scheduler.add_job(taskcontroller.run_whiltlist_task, 'interval', hours=2) # parsing the table package_committer_excels scheduler.add_job(taskcontroller.run_package_committer_task, 'interval', hours=1) # Parse the issue statistics recipient list # scheduler.add_job(taskcontroller.issue_statistics_email_task, 'cron', day_of_week='0-6', hour=5, minute=30) # Complete the template information of the issue with the data on the CVE official website scheduler.add_job(taskcontroller.supplement_cve_task, 'interval', minutes=20) scheduler.add_job(taskcontroller.long_supplement_cve_task, 'cron', day_of_week='0-6', hour=1, minute=30) # Parse opengauss yaml file scheduler.add_job(taskcontroller.parse_opengauss_yaml_task, 'cron', day_of_week='0-6', hour=2, minute=30) # Parse the yaml file of mindspore scheduler.add_job(taskcontroller.parse_mindspore_yaml_task, 'cron', day_of_week='0-6', hour=3, minute=30) # Parse the yaml file of openLooKeng # scheduler.add_job(taskcontroller.parse_openlookeng_yaml_task, 'cron', day_of_week='0-6', hour=4, minute=30) scheduler.start() except SystemExit as err: print("Err:", err)
# Load configuration from the environment if available for key, value in default_config.items(): app.config[key] = os.environ.get(key, value) # Base application flask_bootstrap.Bootstrap(app) db = flask_sqlalchemy.SQLAlchemy(app) migrate = flask_migrate.Migrate(app, db) # Manager commnad manager = flask_script.Manager(app) manager.add_command('db', flask_migrate.MigrateCommand) # Task scheduling scheduler = background.BackgroundScheduler({ 'apscheduler.timezone': 'UTC' }) if not app.debug or os.environ.get('WERKZEUG_RUN_MAIN') == 'true': scheduler.start() from mailu import tlstasks # Babel configuration babel = flask_babel.Babel(app) translations = list(map(str, babel.list_translations())) @babel.localeselector def get_locale(): return flask.request.accept_languages.best_match(translations) # Login configuration login_manager = flask_login.LoginManager()