I am trying to get the current recursion depth of a python script at a particular time in the script. The function getrecursiondepth() was suggested to me but I keep getting the error that such function does not exist in the sys.pyi module.
Does this function really not exist at all in any existing python module and if not is there any other way I can go about getting the recursion depth I need?
Note: I am not looking to get the recursion limit, just the recursion depth.
Here is the code that was suggested to me:
def recursion_depth():
depth = sys.getrecursiondepth()
with open("recursion_depth.txt", "a") as f:
f.write(f"Recursion depth: {depth}\n")
if depth < sys.getrecursionlimit():
recursion_depth()
recursion_depth()