From 5a3e7fe8eef5fbba508e97f67bbc2f25f58c9aca Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Sat, 30 Mar 2024 21:28:42 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A6=81=E6=AD=A2=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.py b/main.py index 8eb1f3c1..d60b34dd 100644 --- a/main.py +++ b/main.py @@ -49,6 +49,19 @@ async def main_entry(): if __name__ == '__main__': + import os + import psutil + + if os.name == 'nt': + allowed_parent_process = ['cmd.exe', 'powershell.exe', 'wsl.exe'] + + parent_process = psutil.Process(os.getppid()).name() + + if parent_process not in allowed_parent_process: + print("请在命令行中运行此程序。") + input("按任意键退出...") + exit(0) + import asyncio asyncio.run(main_entry())