Python script stops running when screen turns off
Asked Answered
W

2

17

I am trying to do a simple bot in Python, I have written the body and I wanted to try it on real data. So I ran it, it runs in an infinite loop and at the end of the loop it sleeps for 6 seconds because it gets data from server and needs to sleep so it does not get kicked from server. Anyway, by the time I sat in front of the PC and was doing my stuff the script was running (I am running it from Windows command prompt) but when I turned off the screen and came back, the script was not running anymore. I have tried this few times with different lengths of the runs of script and always it stopped after i turned off the screen.

  • How to keep python script running once the computer screen is turned off
Writing answered 7/7, 2018 at 10:34 Comment(3)
I need some more information. Can you edit your question to post with your code? How about reading this?Slave
In which mode does your computer get once you turn off the screen?Prevaricate
It does not perform any action upon closing, i have checked it but i will check some more options..Writing
P
16

Check "Power Options" in the Control panel.

You don't need to worry about the screen locking or turning off as these wont affect running processes in python. However, if your system is set to sleep after a set amount of time you may need to change this to Never. Keep in mind there are separate settings depending on whether or not the system is plugged in.

Prevaricate answered 7/7, 2018 at 10:47 Comment(3)
okay, the PC was set to sleep after 15 minutes, but the script only ran 4-5 minutes. I set it to never sleep, I w ill see what will be the output and inform you then. I also tried not turning off the HDD (dont know if that affects something, but as I said, we will see). By the time thanks for answer.Writing
Okay the results by now are that i have closed the laptop and went away fór 24 min and the program is running when i came back. ThanksWriting
This is generally true but I'm dealing with an issue right now where network requests do not work when the computer "sleeps" or enters power save. Computer cuts power to wireless chips and causes the threads to get "stuck" in whatever network request they're currently making.Sash
K
1

Change "Battery saver" mode to "Best Performance" mode. This worked for me, in continue running the scripts when screen turned off

Knutson answered 14/7, 2021 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.