Forums

Python bot stops every ~3 days, can't figure out why

I'm hosting a Python bot for Reddit that will perform a check every 15 minutes (using time.sleep(900)), each time this check is performed it takes 10-20 real seconds, and ~0.3 CPU-seconds -- I have never hit the CPU usage daily limit.

However, every ~3 days or so the bot will stop running and I will get complaints from users. When I go to look at the Bash console I ran it in a few days ago, it is just an empty console, as if I never ran it from the beginning.

What is the cause of this? Mathematically I'm never hitting the CPU-usage daily limit so I wouldn't think it'd be that. Thanks! If you need more information I am happy to provide it.

I'm guessing that the folks over at pythonanywhere restart the servers every ~3 days. During which, they probably turned off your bot during the process.

I get something similar - see https://www.pythonanywhere.com/forums/topic/5107/ , but I actually I get a blank screen, and then the console starts loading from scratch. Your screenshot looks to me like your program terminated due to an error.

The funny thing is that I've got 5 Bash console sessions running, and often the mysterious 'death' only affects two or three of them. It happens on average every two days.

Jim

Yup. This is because we have a bunch of different servers that run your consoles, so restarts etc may only affect some of them. Definitely look into using long running tasks here.