更新push逻辑,尝试解决丢数据的bug

This commit is contained in:
murmur 2023-04-03 10:24:24 +08:00
parent 4fe8abc6be
commit 2e4f59fbd1

View File

@ -55,6 +55,7 @@ _{datetime.datetime.now()}_
Timer(10,s2wx).start() Timer(10,s2wx).start()
return return
pushisbusy=1 pushisbusy=1
le = len(msgcache)
def send(): def send():
c= " \n".join(msgcache[:3]) c= " \n".join(msgcache[:3])
res = requests.post("http://push.nmhd.eu.org:12722/push/murmur", json={ res = requests.post("http://push.nmhd.eu.org:12722/push/murmur", json={
@ -80,21 +81,16 @@ _{datetime.datetime.now()}_
# else: # else:
# return res["message"] # return res["message"]
if len(msgcache) >3: if le >2:
send() send()
if len(msgcache): msgcache.pop(0)
msgcache.pop(0) msgcache.pop(0)
if len(msgcache): msgcache.pop(0)
msgcache.pop(0)
if len(msgcache):
msgcache.pop(0)
Timer(10,s2wx).start() Timer(10,s2wx).start()
elif (not len(content)) and len(msgcache): elif (not len(content)) and le:
# 等效超时 # 等效超时
send() send()
if len(msgcache): for i in le:
msgcache.pop(0)
if len(msgcache):
msgcache.pop(0) msgcache.pop(0)
Timer(10,s2wx).start() Timer(10,s2wx).start()
pushisbusy=0 pushisbusy=0