diff --git a/README.md b/README.md index 891603e..558bd57 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ python main.py # 运行项目 ### 直接部署 -环境要求:Python 3.8+ -没有其他限制,能用 Python 理论上就能跑起来 -如果需要部署 flask 版本,请将 main.py 自行换成 main-flask.py +环境要求:Python 3.6+, 建议Python 3.8+ +没有其他限制,能用 Python 理论上就能跑起来 +flask版本即将停止支持,不建议使用 测试版本部署,linux 命令如果为 python3 请自行替换: ```bash diff --git a/common/variable.py b/common/variable.py index 5a9a198..138bf9d 100644 --- a/common/variable.py +++ b/common/variable.py @@ -36,10 +36,12 @@ def _read_config(key): return value except: return None - -debug_mode = debug_mode if (debug_mode := _read_config("common.debug_mode")) else False -log_length_limit = log_length_limit if (log_length_limit := _read_config("common.log_length_limit")) else 500 -log_file = log_file if (not isinstance(log_file := _read_config("common.log_file"), type(None))) else True +_dm = _read_config("common.debug_mode") +_lm = _read_config("common.log_file") +_ll = _read_config("common.log_length_limit") +debug_mode = _dm if (_dm) else False +log_length_limit = _ll if (_ll) else 500 +log_file = _lm if (not isinstance(_lm , type(None))) else True running = True config = {} workdir = _os.getcwd() diff --git a/main.py b/main.py index a781fb2..9e1eb49 100644 --- a/main.py +++ b/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]"):