diff --git a/main.py b/main.py index 2e93d7f..06cf744 100644 --- a/main.py +++ b/main.py @@ -241,7 +241,7 @@ class GroupDailyAnalysis(Star): # 2. 停止各个组件 if self.auto_scheduler: logger.info("正在停止自动调度器...") - self.auto_scheduler.schedule_jobs(None) # type: ignore + self.auto_scheduler.unschedule_jobs(self.context) if self.retry_manager: await self.retry_manager.stop() diff --git a/src/infrastructure/scheduler/auto_scheduler.py b/src/infrastructure/scheduler/auto_scheduler.py index e46f14d..83d7197 100644 --- a/src/infrastructure/scheduler/auto_scheduler.py +++ b/src/infrastructure/scheduler/auto_scheduler.py @@ -269,7 +269,13 @@ class AutoScheduler: def unschedule_jobs(self, context): """取消定时任务""" + if not context or not hasattr(context, "cron_manager") or not context.cron_manager: + return + scheduler = context.cron_manager.scheduler + if not scheduler: + return + for job_id in self.scheduler_job_ids: try: if scheduler.get_job(job_id):