Forums

Console Closing even though I know the code hasn't finished

Hi, my console is closing even though I know the code hasn't finished running. I have plenty of CPU seconds left, so I'm wondering what the issue is. I've run the code on my own computer just to see if it was indeed reaching the end of what it needed to do, and it continues to run beyond the point that the pythonanywhere closes. Can anyone explain this? Thanks

Hi Gildash,

There are a couple possibilities- for example- your code could be consuming memory exponentially and getting killed.

Alternatively, if you are seeing this just every week or two, it is likely that we are just restarting servers for maintenance/upgrades etc.

To keep a task running forever, see this.

So, to be clear: PythonAnywhere will kill programs that grow beyond a certain rate? As in a put the values of a list through a function that increases the number of elements in the list as a function of those already existing elements:

[1,2] -> [1-1,1+1,2-1,2+1]: [0,2,1,3] -> [0-1,0+1,2-1,2+1,1-1,1+1,3-1,3+1]: [-1,1,1,3,0,2,2,4], etc....

The size in the above increases as a series 2,4,8,16, etc.... The function that I'm using increases the list size by about 3 times each iteration. So its size increases by (original size)*3^i where i is the number of iterations, so I guess you could consider it even steeper than an exponential function.

Why is this a problem for pythonanywhere? What changes can I make to my program so you guys don't automatically terminate it? It hasn't been a problem with other programs that I've used. Thanks!

We terminate processes that use up too much memory, because other users also need memory and it's usually an indication of a bug in the code.

Understood, but can you address my question about what I can do to work around this? The function I described is quite common in combinatorics and permutation problem solving.

Without any actual code, all I can say is "don't build gigantic lists in memory"

Interesting exchange - any chance of some memory numbers from both of you, to quantify things? ;---)

Awesome support staff here. You can really tell from the answers that they care.

Yep!

Uh. That really wasn't meant to be rude and I apologise if that's the way it seemed. It was the best answer that I could come up with with the information available. I don't do combinatorics or permutations much, so I don't recognise the function and have no way of knowing if there's a better way of generating the values.

@jgmdavies: the current kill level is 3G

@glenn I don't think you were rude, and 3GB seems entirely reasonable.

@Gildash Any idea how much memory your prog is taking (or needing), typically?