From eb3bbf73db85746be8cb0184af2a1f38c45dc794 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Wed, 9 Nov 2022 02:30:39 +0800 Subject: [PATCH] feat/add retry --- BDSM/toot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/BDSM/toot.py b/BDSM/toot.py index e9ecb69..5b91781 100644 --- a/BDSM/toot.py +++ b/BDSM/toot.py @@ -222,7 +222,7 @@ def toot_process(statuses, my_acct, duplicates_counter=0): # poll_id,emoji_list,visibility,reblogged,favourited,bookmarked,sensitive,reblogs_count,favourites_count,language)) return duplicates_counter -# @retry(stop=stop_after_attempt(7)) + def archive_toot(url, archive_match): mastodon, user = app_login(url) acct = mastodon.me().acct @@ -240,7 +240,11 @@ def archive_toot(url, archive_match): print("检测到重复嘟文达到十次,取消存档……") break - statuses = mastodon.fetch_next(statuses) + @retry(stop=stop_after_attempt(5)) + def archive_retry(): + return mastodon.fetch_next(statuses) + + statuses = archive_retry() if statuses == None: break