refactor: 移除重算脚本部署,autocommit模式,2秒轮询
This commit is contained in:
@@ -77,7 +77,8 @@ class ImageSimilarityChecker:
|
||||
password=self.config.get('database', 'password'),
|
||||
database=self.config.get('database', 'database'),
|
||||
charset=self.config.get('database', 'charset'),
|
||||
cursorclass=pymysql.cursors.DictCursor
|
||||
cursorclass=pymysql.cursors.DictCursor,
|
||||
autocommit=True
|
||||
)
|
||||
self.logger.info("数据库连接成功")
|
||||
|
||||
@@ -254,7 +255,6 @@ class ImageSimilarityChecker:
|
||||
WHERE id = %s
|
||||
"""
|
||||
cursor.execute(sql, (similar_id, score, image_id))
|
||||
self.db_conn.commit()
|
||||
self.logger.info(f"重复: {image_id} -> {similar_id} (分数={score:.4f})")
|
||||
|
||||
def update_as_unique(self, image_id: int):
|
||||
@@ -268,7 +268,6 @@ class ImageSimilarityChecker:
|
||||
WHERE id = %s
|
||||
"""
|
||||
cursor.execute(sql, (image_id,))
|
||||
self.db_conn.commit()
|
||||
self.logger.info(f"不重复: {image_id} -> tag_extension")
|
||||
|
||||
def update_as_failed(self, image_id: int, reason: str):
|
||||
@@ -282,7 +281,6 @@ class ImageSimilarityChecker:
|
||||
WHERE id = %s
|
||||
"""
|
||||
cursor.execute(sql, (image_id,))
|
||||
self.db_conn.commit()
|
||||
|
||||
def process_batch(self, image_records: List[dict]) -> Tuple[int, int, int]:
|
||||
"""处理一批图片,返回 (重复数, 不重复数, 失败数)"""
|
||||
@@ -360,8 +358,8 @@ class ImageSimilarityChecker:
|
||||
images = self.get_draft_images()
|
||||
|
||||
if not images:
|
||||
self.logger.info("没有待处理的图片,等待 10 秒后继续检查...")
|
||||
time.sleep(10)
|
||||
self.logger.info("没有待处理的图片,等待 2 秒后继续检查...")
|
||||
time.sleep(2)
|
||||
continue
|
||||
|
||||
batch_num += 1
|
||||
|
||||
Reference in New Issue
Block a user