本文整理汇总了Python中apscheduler.jobstores.sqlalchemy.SQLAlchemyJobStore方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.SQLAlchemyJobStore方法的具体用法?Python sqlalchemy.SQLAlchemyJobStore怎么用?Python sqlalchemy.SQLAlchemyJobStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apscheduler.jobstores.sqlalchemy
的用法示例。
在下文中一共展示了sqlalchemy.SQLAlchemyJobStore方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def __init__(self, datastore_dir, threat_max, timezone):
global _scheduler_
self.timezone = timezone
lock = threading.Lock()
with lock:
if not _scheduler_:
jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///{}/scheduler.sqlite'.format(datastore_dir)),
}
executors = {
'default': ThreadPoolExecutor(threat_max),
}
job_defaults = {
'coalesce': False,
'max_instances': 1
}
_scheduler_ = BackgroundScheduler(
jobstores=jobstores, executors=executors,
job_defaults=job_defaults, timezone=timezone
)
_scheduler_.start()
示例2: get_scheduler
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def get_scheduler(store_path=None, log_file=None):
if store_path is None:
store_path = r'jobstore.sqlite'
if log_file is None:
log_file = r'logger.log'
scheduler = BackgroundScheduler({'apscheduler.timezone': 'Asia/Shanghai'})
jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///{0}'.format(store_path))
}
executors = {
'default': ThreadPoolExecutor(20),
'processpool': ProcessPoolExecutor(5)
}
job_defaults = {
'coalesce': False,
'max_instances': 1
}
scheduler.configure(jobstores=jobstores, executors=executors)
# 事件记录
scheduler.add_listener(
lambda event: event_listener(event, scheduler),
EVENT_JOB_EXECUTED | EVENT_JOB_ERROR | EVENT_JOB_ADDED | EVENT_JOB_SUBMITTED | EVENT_JOB_REMOVED
)
# 日志定制
scheduler._logger = modify_logger(scheduler._logger, log_file=log_file)
return scheduler
示例3: __init__
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def __init__(self, clist_user_name, clist_api_key, mount_point, bot, fallback):
self.clist_user_name = clist_user_name
self.clist_api_key = clist_api_key
self.bot = bot
self.ong = None
self.upc = None
self.mount_point = mount_point
self.utility = ContestUtility(mount_point)
self.jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///' + mount_point + 'coders1.db')
}
self.schedule = BackgroundScheduler(jobstores=self.jobstores)
self.schedule.start()
self.conv_handler = ConversationHandler(
entry_points=[CommandHandler('upcoming', self.upcoming)],
allow_reentry=True,
states={
SCHED: [CallbackQueryHandler(self.remind, pattern=r"^[0-9]*$")]
},
fallbacks=[fallback]
)
self.conv_handler1 = ConversationHandler(
entry_points=[CommandHandler('dontRemindMe', self.removeRemind)],
allow_reentry=True,
states={
REMNOTI: [CallbackQueryHandler(self.remnoti, pattern=r'^.*notiplz.*$')]
},
fallbacks=[fallback]
)
示例4: start_scheduler
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def start_scheduler(settings):
assert settings['scheduler.store'] in ('redis', 'sqlalchemy'),\
'Uknown job store, must by one of redis or sqlalchemy'
if settings['scheduler.store'] == 'redis':
jobstores = {
'default': RedisJobStore(db=settings['scheduler.db'])
}
else:
jobstores = {
'default': SQLAlchemyJobStore(url=settings['scheduler.url'])
}
executors = {
'default': {
'type': settings['scheduler.executors.type'],
'max_workers': settings['scheduler.executors.max_workers']
},
'processpool': ProcessPoolExecutor(
max_workers=settings['scheduler.executors.processpool.max_workers']
)
}
job_defaults = {
'coalesce': False,
'max_instances': settings['scheduler.job_defaults.max_instances']
}
scheduler.configure(
jobstores=jobstores,
executors=executors,
job_defaults=job_defaults,
timezone=timezone('UTC')
)
if settings['scheduler.autostart'] == 'true':
scheduler.start()
示例5: start
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def start(self, scheduler, alias):
# There should be called 'start' method of parent of SQLAlchemyJobStore
super(self.__class__.__bases__[0], self).start(scheduler, alias)
示例6: start_sched
# 需要导入模块: from apscheduler.jobstores import sqlalchemy [as 别名]
# 或者: from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore [as 别名]
def start_sched():
sched.configure(jobstores={
'default': SQLAlchemyJobStore(url=settings.SCHEDULER_DB_URL)
})
log.info("Starting scheduler")
sched.start()
return sched