fix: 增强删除配置时同步服务的停止逻辑

- close() 方法中先设置停止标志
- 强制设置 _sync_in_progress = False
- 确保取消正在运行的自动同步任务
This commit is contained in:
linlin 2026-03-13 17:14:08 +08:00
parent 0a839523fd
commit 31e5a61f4a
1 changed files with 16 additions and 1 deletions

View File

@ -556,9 +556,24 @@ class SyncService:
def close(self):
"""Close connections for this data source"""
self.stop_auto_sync()
# 先设置停止标志,防止新同步开始
self._running = False
self._sync_in_progress = False
# 取消自动同步任务
if hasattr(self, '_auto_sync_task') and self._auto_sync_task is not None and not self._auto_sync_task.done():
try:
self._auto_sync_task.cancel()
except Exception as e:
logger.error(f"Error cancelling auto sync task: {e}")
# 停止当前同步
self._sync_in_progress = False
if hasattr(self.syncer, 'close'):
self.syncer.close()
logger.info(f"Closed all connections for {self.source_name}")
class SyncServiceManager: