add retry

This commit is contained in:
felinae98 2021-03-03 20:36:48 +08:00
parent 88dead62e2
commit 33a969e782
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 11 additions and 1 deletions

View File

@ -208,7 +208,15 @@ class PlatformNoTarget(PlatformProto):
async def _parse_with_cache(self, post: RawPost) -> Post:
post_id = self.get_id(post)
if post_id not in self.cache:
self.cache[post_id] = await self.parse(post)
retry_times = 3
while retry_times:
try:
self.cache[post_id] = await self.parse(post)
break
except Exception as err:
if not retry_times:
raise err
retry_times -= 1
return self.cache[post_id]
async def filter_common(self, raw_post_list: list[RawPost]) -> list[RawPost]:

View File

@ -89,6 +89,8 @@ class Weibo(Platform):
await super().filter_common(target, raw_post_list)
return []
else:
if not raw_post_list:
return []
new_post = self._get_top(raw_post_list)
res = await super().filter_common(target, raw_post_list)
if (self.top[target] is not None and new_post is None) or \