From the documentation :
sys.getrecursionlimit()
Returns the current value of the recursion limit, the maximum depth of the Python interpreter stack. This limit prevents infinite recursion due to C and Python crashing. Setrecursionlimit () may be set.
I am currently pushing the recursion limit when etching an object. The object that I am etching has several levels of nesting, so I am a little puzzled by what is happening.
I managed to get around the problem with the following hack:
try:
return pickle.dumps(x)
except:
try:
recursionlimit = getrecursionlimit()
setrecursionlimit(2*recursionlimit)
dumped = pickle.dumps(x)
setrecursionlimit(recursionlimit)
return dumped
except:
raise
Testing the above snippet in different contexts sometimes leads to success in the first try, and sometimes leads to success in the second try. So far, I have not been able to make an exception raise.
, . , , try .
, , , ?
def get_stack_depth():