mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
add retry
This commit is contained in:
parent
88dead62e2
commit
33a969e782
@ -208,7 +208,15 @@ class PlatformNoTarget(PlatformProto):
|
|||||||
async def _parse_with_cache(self, post: RawPost) -> Post:
|
async def _parse_with_cache(self, post: RawPost) -> Post:
|
||||||
post_id = self.get_id(post)
|
post_id = self.get_id(post)
|
||||||
if post_id not in self.cache:
|
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]
|
return self.cache[post_id]
|
||||||
|
|
||||||
async def filter_common(self, raw_post_list: list[RawPost]) -> list[RawPost]:
|
async def filter_common(self, raw_post_list: list[RawPost]) -> list[RawPost]:
|
||||||
|
@ -89,6 +89,8 @@ class Weibo(Platform):
|
|||||||
await super().filter_common(target, raw_post_list)
|
await super().filter_common(target, raw_post_list)
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
|
if not raw_post_list:
|
||||||
|
return []
|
||||||
new_post = self._get_top(raw_post_list)
|
new_post = self._get_top(raw_post_list)
|
||||||
res = await super().filter_common(target, 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 \
|
if (self.top[target] is not None and new_post is None) or \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user