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: