Forums

CPU seconds keep adding up when I use time.sleep()

Context:

Most of my script is idle, waiting for the sleep() func to call. I timed my program and it should be active for at maximum 150 "cpu seconds" a day. But with 6 of these programs running (maximum 900 cpu seconds a day), it surpasses 13,000 "cpu seconds" and always goes into the tarpit.

Question:

Does pythonanywhere count the seconds when my script hits func sleep()? Is there another way to optimize cpu seconds that I'm not aware of?

There must be something different eating your CPU seconds. It's not time.sleep() What are your scripts doing in general?

I made my own Instagram scheduler where each script posts 2-3 photos per day to Instagram. Would Selenium be eating up the CPU time if I'm idle on the browser?

If it helps to know, my scripts are meant to run 24/7. I measured the CPU time per script where one script uses 3,456 CPU seconds every 24 hours. This is 2.4 CPU seconds per minute (even when idle) so I assume it's not the script itself, but either Selenium is taking up a lot of CPU usage or it's something else

The browser is likely to be using CPU the whole time you have it open. Particularly, if it's looking at a page that has javascript that is updating the content on the page.

You might be onto something Glenn... thank you!