You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 07:39:05