mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-10 09:47:26 +08:00
[Bug Fix][Enhance] Endless loop & waitress log
- Fix a bug due to 6fcca17918 that there is a endless loop in calculating recent 10 updating
- Add info log for `waitress`
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
# log files
|
# log files
|
||||||
*.log
|
*.log
|
||||||
|
*.log.*
|
||||||
|
|
||||||
# SSL cert
|
# SSL cert
|
||||||
*.pem
|
*.pem
|
||||||
|
|||||||
@@ -380,12 +380,12 @@ class UserPlay(UserScore):
|
|||||||
r30_id = 29
|
r30_id = 29
|
||||||
elif self.song.song_id_difficulty in songs and n == 10:
|
elif self.song.song_id_difficulty in songs and n == 10:
|
||||||
i = 29
|
i = 29
|
||||||
while self.ptt.s30[i] == self.song.song_id_difficulty:
|
while self.ptt.s30[i] == self.song.song_id_difficulty and i > 0:
|
||||||
i -= 1
|
i -= 1
|
||||||
r30_id = i
|
r30_id = i
|
||||||
elif self.song.song_id_difficulty not in songs and n == 9:
|
elif self.song.song_id_difficulty not in songs and n == 9:
|
||||||
i = 29
|
i = 29
|
||||||
while self.ptt.s30.count(self.ptt.s30[-1]) == 1:
|
while self.ptt.s30.count(self.ptt.s30[i]) == 1 and i > 0:
|
||||||
i -= 1
|
i -= 1
|
||||||
r30_id = i
|
r30_id = i
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class Connect:
|
|||||||
返回:sqlite3连接操作对象
|
返回:sqlite3连接操作对象
|
||||||
"""
|
"""
|
||||||
self.file_path = file_path
|
self.file_path = file_path
|
||||||
self.in_memory = in_memory
|
self.in_memory: bool = in_memory
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self) -> sqlite3.Cursor:
|
||||||
if self.in_memory:
|
if self.in_memory:
|
||||||
self.conn = sqlite3.connect(
|
self.conn = sqlite3.connect(
|
||||||
'file:arc_tmp?mode=memory&cache=shared', uri=True, timeout=10)
|
'file:arc_tmp?mode=memory&cache=shared', uri=True, timeout=10)
|
||||||
@@ -35,15 +35,13 @@ class Connect:
|
|||||||
if issubclass(exc_type, ArcError):
|
if issubclass(exc_type, ArcError):
|
||||||
flag = False
|
flag = False
|
||||||
else:
|
else:
|
||||||
if self.conn:
|
self.conn.rollback()
|
||||||
self.conn.rollback()
|
|
||||||
|
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
traceback.format_exception(exc_type, exc_val, exc_tb))
|
traceback.format_exception(exc_type, exc_val, exc_tb))
|
||||||
|
|
||||||
if self.conn:
|
self.conn.commit()
|
||||||
self.conn.commit()
|
self.conn.close()
|
||||||
self.conn.close()
|
|
||||||
|
|
||||||
return flag
|
return flag
|
||||||
|
|
||||||
|
|||||||
@@ -629,9 +629,9 @@ class UserInfo(User):
|
|||||||
|
|
||||||
def update_global_rank(self) -> None:
|
def update_global_rank(self) -> None:
|
||||||
'''用户世界排名计算,有新增成绩则要更新'''
|
'''用户世界排名计算,有新增成绩则要更新'''
|
||||||
with Connect() as c2:
|
|
||||||
c2.execute('''select song_id, rating_ftr, rating_byn from chart''')
|
self.c.execute('''select song_id, rating_ftr, rating_byn from chart''')
|
||||||
x = c2.fetchall()
|
x = self.c.fetchall()
|
||||||
|
|
||||||
song_list_ftr = [self.user_id]
|
song_list_ftr = [self.user_id]
|
||||||
song_list_byn = [self.user_id]
|
song_list_byn = [self.user_id]
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ def download(file_path):
|
|||||||
return error_return()
|
return error_return()
|
||||||
|
|
||||||
|
|
||||||
|
if Config.DEPLOY_MODE == 'waitress':
|
||||||
|
# 给waitress加个日志
|
||||||
|
@app.after_request
|
||||||
|
def after_request(response):
|
||||||
|
app.logger.info(
|
||||||
|
f'B {request.remote_addr} - - {request.method} {request.path} {response.status_code}')
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def tcp_server_run():
|
def tcp_server_run():
|
||||||
if Config.DEPLOY_MODE == 'gevent':
|
if Config.DEPLOY_MODE == 'gevent':
|
||||||
# 异步 gevent WSGI server
|
# 异步 gevent WSGI server
|
||||||
|
|||||||
Reference in New Issue
Block a user