Skip to content

Commit

Permalink
新增一个回帖异常处理
Browse files Browse the repository at this point in the history
遇到502错误时重试
  • Loading branch information
pooneyy committed Oct 24, 2023
1 parent b7bd054 commit f411fe5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
### 更新日志

```
2023.10.24-Based-0.23.10.24.1
从上游仓库同步更新,Commit:“新增一个回帖异常处理 (#31)”
发帖遇到502错误时重试
2023.09.13-Based-0.23.09.07.1
smtp模块新增 开启 / 关闭 SSL选项
基于smtp的日志投递模块新增 开启 / 关闭 SSL选项
2023.09.07-Based-0.23.09.07.1
从上游仓库同步更新,Commit:“修正一处文本描述的错误 (#30)”
Expand Down
18 changes: 10 additions & 8 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

DEBUG = False

__verison__ = "2023.09.13-Based-0.23.09.07.1"
__verison__ = "2023.10.24-Based-0.23.10.24.1"

def outputLog(projectName):
log = logging.getLogger(f"{projectName}")
Expand Down Expand Up @@ -96,13 +96,12 @@ def deco(*args , **kargs):
return deco

def save_cookies(session : requests.Session , filename : str) -> None:
...
# with open(filename, 'wb') as f:
# try:
# pickle.dump(session.cookies, f)
# log.debug(f"save {filename} success")
# except:
# ...
try:
with open(filename, 'wb') as f:
pickle.dump(session.cookies, f)
log.debug(f"save {filename} success")
except:
...

def load_cookies(session : requests.Session , filename : str) -> None:
with open(filename, 'rb') as f:
Expand Down Expand Up @@ -348,6 +347,9 @@ def reply(self, url) -> bool:
elif res.text.find("該貼已被鎖定") != -1:
log.info(f"{self.username} reply failed , the thread is locked")
return True
elif res.text.find("502 Bad Gateway") != -1:
log.info(f"{self.username} reply failed , HTTP 502 Error")
return True
else:
log.error(f"{self.username} reply {url} failed , unknown error")
log.error(res.text)
Expand Down

0 comments on commit f411fe5

Please sign in to comment.