in memory_analyzer/gdb_commands.py [0:0]
def lock_GIL(func):
def wrapper(*args):
out = gdb.execute("call (void*) PyGILState_Ensure()", to_string=True)
gil_value = next((x for x in out.split() if x.startswith("$")), "$1")
print("GIL", gil_value)
func(*args)
call = "call (void) PyGILState_Release(" + gil_value + ")"
gdb.execute(call)
return wrapper