简体   繁体   English

后台运行Python脚本不断停止

[英]Background Running Python Script keeps stopping

I made a .pyw python script that I want to have running in the background of my computer. 我制作了一个.pyw python脚本,我想在我的电脑后台运行。
Right now I have it set to launch by putting it in the Startup folder of my Windows 7 computer, which should trigger it to launch whenever it starts up. 现在我将它设置为启动,方法是将它放在我的Windows 7计算机的Startup文件夹中,该文件夹应该在启动时触发它。

The problem is that the script seems to stop running at some point for some reason. 问题是由于某种原因,脚本似乎在某些时候停止运行。 I think it simply stops when my computer goes to sleep and doesn't start running again afterwards. 我认为它只是在我的电脑进入睡眠状态时停止并且之后不再开始运行。

Is there a "more correct" way to have a background task running that wouldn't have it die every time the computer goes to sleep? 是否有一种“更正确”的方式来运行后台任务,每次计算机进入睡眠状态时都不会死机?

If there really is need for a continuously running background process, you should look into making a service. 如果确实需要持续运行的后台进程,您应该考虑制作服务。

pywin32 helps in creating NT services with python pywin32有助于使用python创建NT服务

If you're into .NET, you can try also IronPython , but I don't know whether that is more easy. 如果你是.NET,你可以尝试IronPython ,但我不知道这是否更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM