Python Forum

Full Version: Current Stack Size
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In an application I am working on, users can traverse a graph. However, when they move on the graph, they are basically adding five function calls to the stack. Since the graph is connected, they could theoretically put enough function calls on the stack to run into the recursion limit. This is not something I expect to be likely. Traversing the graph is not the main function of the application, and it would be rather extreme to do it the 200 times it would take to hit the recursion limit (on my machine at least). But I have a feeling that someday, someone is going to try it, if only because they can.

Now, I know how to determine and change the recursion limit. It looks like the traceback module has way to explore the stack. But I couldn't find anything that just told me how big the stack was, or how close it was to the recursion limit. Does anyone know a simple way to get just that information? Or would I need to pull a summary of the whole stack using traceback and measure it myself?
I have this post: https://python-forum.io/Thread-Walking-t...ight=stack
sorry, don't remember exactly how it works, but should be easy enough to figure out. It traverses the stack, so has to know what's in it.