Added infinite loop detection

This commit is contained in:
codemann8
2021-12-21 10:35:54 -06:00
parent a731bc0799
commit 0df739b283
3 changed files with 24 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import sys
import xml.etree.ElementTree as ET
from collections import defaultdict
from functools import reduce
from itertools import count
def int16_as_bytes(value):
@@ -674,6 +675,21 @@ def extract_data_from_jp_rom(rom):
print()
def stack_size3a(size=2):
# See reference: https://stackoverflow.com/questions/34115298/how-do-i-get-the-current-depth-of-the-python-interpreter-stack
"""Get stack size for caller's frame."""
frame = sys._getframe(size)
try:
for size in count(size, 8):
frame = frame.f_back.f_back.f_back.f_back.\
f_back.f_back.f_back.f_back
except AttributeError:
while frame:
frame = frame.f_back
size += 1
return size - 1
class bidict(dict):
def __init__(self, *args, **kwargs):
super(bidict, self).__init__(*args, **kwargs)