#!/usr/bin/env python3# -*- coding: utf-8 -*-"""# @Version : Python 3.11.4# @Software : Sublime Text 4# @Author : StudentCWZ# @Email : StudentCWZ@outlook.com# @Date : 2023/11/11 15:15# @File : apscheduler.py# @Description :"""fromflask_apschedulerimportAPSchedulerasBaseAPSchedulerclassAPScheduler(BaseAPScheduler):""" A custom APScheduler with context management. This allows the scheduler to work with Flask's application context, which is necessary for tasks that interact with the database. """defrun_job(self,_id,_job=None):""" Run a job with Flask's application context. :param _id: The ID of the job to run. :param _job: The job store alias. """withself.app.app_context():super().run_job(id=_id,jobstore=_job)