Added infinite loop detection
This commit is contained in:
16
Utils.py
16
Utils.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user