From 1eddfd07cad491ce8d216ee3fda72bdd9ecb9eae Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 20 Jul 2025 13:43:17 -0600 Subject: Aergia.get_deepest_traceable_frame refactor, tests Generators and list comprehension gives correct but less ideal results, matching yappi. Can this be improved in the future? --- aergia/aergia.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'aergia') diff --git a/aergia/aergia.py b/aergia/aergia.py index d8f18ec..83cf0fa 100755 --- a/aergia/aergia.py +++ b/aergia/aergia.py @@ -247,20 +247,15 @@ class Aergia(object): @staticmethod def get_deepest_traceable_frame(coro): - if not coro: - return None curr = coro - lframe = None - while True: + ret = None + while curr: frame = getattr(curr, 'cr_frame', None) - if not frame or not Aergia.should_trace(frame.f_code.co_filename): - return lframe - - lframe = frame - awaited = getattr(curr, 'cr_await', None) - if not awaited or not hasattr(awaited, 'cr_frame'): - return lframe - curr = awaited + # print(frame) + if frame and Aergia.should_trace(frame.f_code.co_filename): + ret = frame + curr = getattr(curr, 'cr_await', None) + return ret @staticmethod def should_trace(filename): -- cgit v1.2.3