Browse Source

retry_count

rambo 1 month ago
parent
commit
bef40bfe30
1 changed files with 14 additions and 10 deletions
  1. 14 10
      python/sockets/message_handler.py

+ 14 - 10
python/sockets/message_handler.py

@@ -72,7 +72,7 @@ def handlerFolderDelete(limit_path, goods_art_no_arrays, is_write_txt_log):
                 except PermissionError as e:
                     retry_count -= 1
                     if retry_count == 0:
-                        logger.info(f"抠图前目录删除出现问题:{str(e)};{goods_art_revice};{cutout_goods}")
+                        logger.info(f"抠图前目录删除出现问题-PermissionError:{str(e)};{goods_art_revice};{cutout_goods}")
                         if is_write_txt_log:
                             error_file_path = f"{cutout_goods}/异常说明-出现目录丢失或缺少图片请点开查看原因.txt"
                             with open(error_file_path, 'w', encoding='utf-8') as f:
@@ -86,16 +86,20 @@ def handlerFolderDelete(limit_path, goods_art_no_arrays, is_write_txt_log):
                     else:
                         time.sleep(0.5)  # 等待0.5秒后重试
                 except Exception as e:
-                    logger.info(f"抠图前目录删除出现问题:{str(e)};{goods_art_revice};{cutout_goods}")
-                    if is_write_txt_log:
-                        error_file_path = f"{cutout_goods}/异常说明-出现目录丢失或缺少图片请点开查看原因.txt"
-                        with open(error_file_path, 'w', encoding='utf-8') as f:
-                            f.write("目录删除失败\n")
-                            f.write(f"原因: {str(e)}\n")
-                            f.write(f"时间: {time.strftime('%Y-%m-%d %H:%M:%S')}\n")
-                            f.write(f"请检查目录状态后,为当前货号点击重拍后重试\n")
+                    retry_count -= 1
+                    if retry_count == 0:
+                        logger.info(f"抠图前目录删除出现问题--Exception:{str(e)};{goods_art_revice};{cutout_goods}")
+                        if is_write_txt_log:
+                            error_file_path = f"{cutout_goods}/异常说明-出现目录丢失或缺少图片请点开查看原因.txt"
+                            with open(error_file_path, 'w', encoding='utf-8') as f:
+                                f.write("目录删除失败\n")
+                                f.write(f"原因: {str(e)}\n")
+                                f.write(f"时间: {time.strftime('%Y-%m-%d %H:%M:%S')}\n")
+                                f.write(f"请检查目录状态后,为当前货号点击重拍后重试\n")
+                        else:
+                            raise UnicornException(f"目录检查出现问题:{str(e)},请关闭错误提示中的被占用文件")
                     else:
-                        raise UnicornException(f"目录检查出现问题:{str(e)},请关闭错误提示中的被占用文件")
+                        time.sleep(0.5)  # 等待0.5秒后重试
     
     return move_folder_array                
 # socket消息发送逻辑处理方法