mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-07-07 06:52:11 +08:00
feat: (wip) 支持Python 3.6 / 3.7
This commit is contained in:
16
main.py
16
main.py
@ -9,6 +9,12 @@
|
||||
# ----------------------------------------
|
||||
# This file is part of the "lx-music-api-server" project.
|
||||
|
||||
import sys
|
||||
|
||||
if (sys.version_info.major < 3 or sys.version_info.minor < 6):
|
||||
print('Python版本过低,请使用Python 3.6+ ')
|
||||
sys.exit(1)
|
||||
|
||||
from common import config
|
||||
from common import lxsecurity
|
||||
from common import log
|
||||
@ -31,6 +37,14 @@ def handleResult(dic, status = 200):
|
||||
logger = log.log("main")
|
||||
aiologger = log.log('aiohttp_web')
|
||||
|
||||
stopEvent = None
|
||||
if (sys.version_info.minor < 8):
|
||||
logger.warning('您使用的Python版本已经停止更新,不建议继续使用')
|
||||
import concurrent
|
||||
stopEvent = concurrent.futures._base.CancelledError
|
||||
else:
|
||||
stopEvent = asyncio.exceptions.CancelledError
|
||||
|
||||
def start_checkcn_thread():
|
||||
threading.Thread(target=Httpx.checkcn).start()
|
||||
|
||||
@ -147,7 +161,7 @@ async def initMain():
|
||||
await run_app()
|
||||
logger.info("服务器启动成功,请按下Ctrl + C停止")
|
||||
await asyncio.Event().wait() # 等待停止事件
|
||||
except (KeyboardInterrupt, asyncio.exceptions.CancelledError):
|
||||
except (KeyboardInterrupt, stopEvent):
|
||||
pass
|
||||
except OSError as e:
|
||||
if str(e).startswith("[Errno 98]"):
|
||||
|
Reference in New Issue
Block a user