Move scheduler staring to Quart's before serving hook

This commit is contained in:
Richard Chien 2019-02-03 11:49:59 +08:00
parent bfba4d1bd4
commit c1486ebbbe

View File

@ -75,9 +75,14 @@ def init(config_object: Optional[Any] = None) -> None:
else:
logger.setLevel(logging.INFO)
_bot.server_app.before_serving(_start_scheduler)
def _start_scheduler():
if scheduler and not scheduler.running:
scheduler.configure(_bot.config.APSCHEDULER_CONFIG)
scheduler.start()
logger.info('Scheduler started')
def get_bot() -> NoneBot: