Forums

Python script stop's after a certain time.

On locally script is running for like 15 days without any issues. It's in infinite loop. When i leave my script open on pythonanywhere after 24 hours when i open the console it starts from scratch. Like I'm starting console on a blank page and not a single output of python script running or so.

Any idea what may be issue here or pythonanywhere is restarting servers and not starting my script ?

Hi, that's intended behaviour -- our consoles are ephemeral by design. If you've got a long running job we've got Always-on tasks feature for that: https://help.pythonanywhere.com/pages/AlwaysOnTasks/.

I just had the same issue. Would it be possible to at least add a message when that happens because I thought something was wrong with my script. And ideally it would also be good to know what the maximum runtime is, did not find that documented anywhere. Is it a fixed limit?

For example I would have a script I would like to run uninterruptedly for a longer time but without restarts, so the always on job would not work there or would it? Are always on jobs never killed that way?

Thanks for your help!

The implementation of the consoles feature would it make very difficult to provide the information you'd like to have, let alone the fact that the reboots of the console servers are part of maintenace process which is dependent on the server state, so that would not be easily schedulable. This is why consoles are by design ephemeral on PythonAnywhere. On the contrary, Always-on tasks are designed in such a way, to enable users to run long running jobs without interruption.

Thanks pafk for the quick reply :) Then if I understand you right if I set the script as an 'always-on task' instead it should run with no interruptions or restarts?

I understand this may be hard to implement in the console. Maybe consider mentioning this in the FAQ or somewhere like that then, could help some new users like me figure out what happened :)

Thank you!

Always-on task would always restart in case of crash or if it exits for any other reason.

Did you run out of CPU Cycles?

I see that always-on tasks are interrupted by system maintenance.

Do they continue where they left off after maintenance or are they restarted?

Also, how often do systems go down for scheduled maintenance?

Thanks!

They're restarted after system maintenance. Right now, system maintenance of that kind tends to happen every few months; in the future, it may be more frequent, but if we do that we'll make sure that we're in a mode where the always-on tasks are just restarted, rather than being switched off temporarily during the maintenance -- that is, it will just look like a restart rather than a short outage.