summaryrefslogtreecommitdiff
path: root/aergia
diff options
context:
space:
mode:
Diffstat (limited to 'aergia')
-rwxr-xr-xaergia/aergia.py36
1 files changed, 4 insertions, 32 deletions
diff --git a/aergia/aergia.py b/aergia/aergia.py
index be7da35..56f345d 100755
--- a/aergia/aergia.py
+++ b/aergia/aergia.py
@@ -291,6 +291,10 @@ class Aergia(object):
@staticmethod
def _get_deepest_traceable_frame(coro):
+ '''Get the deepest frame of coro we care to trace.
+ Since coro is a suspended task, we know that the frame we are
+ looking for belongs to a COROUTINE. Else, it cannot be the case
+ it is suspended.'''
curr = coro
deepest_frame = None
while curr:
@@ -298,38 +302,6 @@ class Aergia(object):
if frame and Aergia._should_trace(frame.f_code.co_filename):
deepest_frame = frame
curr = getattr(curr, 'cr_await', None)
-
- # we are not awaiting anything.
- # either: we did a standard call to a non-coroutine
- # or: we are awaiting an async generator (handled very differently)
- # or: we are awaiting or called a library function which we do not
- # care to profile.
- #
- # first case:
- # second case: we'd like to trace that frame down as far as possible.
- # unless it leads to another task's coroutine, in which
- # case we'll politely decline to count it twice.
- # third case: we'd like to return the current value of deepest_frame.
-
- previous_frame = None
- # print('-' * 60)
- # print('--- Frame Information for ---')
- # print(deepest_frame)
- # print(f"{'Filename':<30} {'Function':<30} {'Line':<10}")
- while previous_frame is not deepest_frame:
- previous_frame = deepest_frame
- refs = gc.get_referrers(deepest_frame)
- for r in refs:
- if inspect.isframe(r) and \
- Aergia._should_trace(r.f_code.co_filename):
- deepest_frame = r
- # co = r.f_code
- # func_name = co.co_name
- # filename = co.co_filename
- # filename = (filename if len(filename) <= 30 else filename[-30:])
- # line_no = r.f_lineno
- # print(f"{filename:<30} {func_name:<30} {line_no:<10}")
- # print(f'finished with {deepest_frame}')
return deepest_frame
@staticmethod