From 9ab12866d3eba47b21f07c86eea0ff1cc44e796b Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 3 Mar 2026 11:43:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=96=E5=A2=9E=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spider/task.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spider/task.py b/spider/task.py index 44402e0..76eea2d 100644 --- a/spider/task.py +++ b/spider/task.py @@ -450,6 +450,11 @@ def retry_get_new_video(page, cookies, post_count): raise TimeoutError("未获取到新视频(可能视频上传失败),已超时") +@retry( + stop=stop_after_attempt(3), + wait=wait_fixed(2), + retry=retry_if_exception(is_operation_failed) +) def playwright_post(cookies, content, image_key=None): path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe') with lock: @@ -483,8 +488,7 @@ def playwright_post(cookies, content, image_key=None): client.fget_object(BUCKET, image_key, file_path) sleep(1, 2) - page.locator('input[accept="image/*,image/heif,image/heic,video/*,video/mp4,video/x-m4v,' - 'video/x-matroska,.mkv"]').set_input_files(file_path) + page.locator('input[accept="image/*,image/heif,image/heic,video/*,video/mp4,video/x-m4v,video/x-matroska,.mkv"]').set_input_files(file_path) time.sleep(5) if not image_key: