perf: 禁止双击运行

This commit is contained in:
RockChinQ
2024-03-30 21:28:42 +08:00
parent 7b3d7e7bd6
commit 5a3e7fe8ee

13
main.py
View File

@@ -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())