初始化zmq 项目
This commit is contained in:
13
rthook.py
Normal file
13
rthook.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import sys
|
||||
import os
|
||||
import multiprocessing
|
||||
|
||||
# 1. 路径自适应:在 Frozen 模式下,将当前工作目录切换到可执行文件所在目录
|
||||
# 这样代码中使用的相对路径(如 './config.ini')就能正确指向 exe 旁边的文件
|
||||
if getattr(sys, 'frozen', False):
|
||||
os.chdir(os.path.dirname(sys.executable))
|
||||
|
||||
# 2. 多进程保护:防止 Windows 下的无限递归炸弹
|
||||
# Windows 下 multiprocessing 需要 freeze_support()
|
||||
if sys.platform.startswith('win'):
|
||||
multiprocessing.freeze_support()
|
||||
Reference in New Issue
Block a user