Ubuntu 20下Suspend-then-hibernate运行Python打包EXE时失效的问题求助
Ubuntu 20下Suspend-then-hibernate运行Python打包EXE时失效的问题求助
各位好,我遇到了一个挺奇怪的问题,想请大家帮忙分析下原因:
我在Intel 11代NUC的Ubuntu 20系统上配置了suspend-then-hibernate功能,正常情况下(系统没有运行代码时)按电源键,系统会先挂起10秒(我在sleep.conf里设置了HibernateDelaySec=10),之后自动进入休眠状态,这部分是完全正常的。
但当我运行一个用多进程写的Python代码时,问题就出现了:按电源键后系统挂起10秒,并没有像预期那样进入休眠,而是又回到挂起状态,反复循环。更费解的是,如果直接运行Python脚本,这个suspend-then-hibernate功能是正常的,但把代码用PyInstaller打包成exe后就失效了。
下面是我的相关配置和操作细节:
1. sleep.conf 配置内容
[Sleep] #AllowSuspend=yes #AllowHibernation=yes AllowSuspendThenHibernate=yes #AllowHybridSleep=yes #SuspendMode= #SuspendState=mem standby freeze HibernateMode=platform shutdown HibernateState=disk #HybridSleepMode=suspend platform shutdown #HybridSleepState=disk HibernateDelaySec=10
2. 执行的关联命令
sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
3. logind.conf 的修改
我还在logind.conf里启用了HandlePowerKey=suspend-then-hibernate选项。
我试过在sleep.conf里开启AllowSuspend、AllowHibernation,指定Suspend模式,但都没能解决问题。现在最核心的疑问就是:为什么直接跑Python脚本时功能正常,打包成exe后就失效了?有没有大佬能解释这个行为?
备注:内容来源于stack exchange,提问作者shear
相关产品推荐
相关产品推荐

