summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xaergia41
1 files changed, 23 insertions, 18 deletions
diff --git a/aergia b/aergia
index 5a601c7..9fd19ef 100755
--- a/aergia
+++ b/aergia
@@ -181,7 +181,7 @@ class Aergia(object):
@staticmethod
def compute_frames_to_record():
'''Collects all stack frames that Aergia actually processes.'''
- frames = Aergia.get_frames_from_runners(Aergia.get_event_loops())
+ frames = Aergia.get_frames_from_loops(Aergia.get_event_loops())
# Process all the frames to remove ones we aren't going to track.
new_frames = []
@@ -212,41 +212,45 @@ class Aergia(object):
@staticmethod
def get_event_loops():
- runners = []
+ loops = []
for t in threading.enumerate():
frame = sys._current_frames().get(t.ident)
if not frame:
continue
- runner = Aergia.walk_back_until_runner(frame)
- if runner:
- runners.append(runner)
- return runners
+ # print(f'searching frame {frame}')
+ loop = Aergia.walk_back_until_loop(frame)
+ if loop:
+ # print(f'found loop {loop}')
+ loops.append(loop)
+ return loops
@staticmethod
- def walk_back_until_runner(frame):
+ def walk_back_until_loop(frame):
while frame:
- r = Aergia.find_runner_in_locals(frame.f_locals)
- if r:
- return r
+ loop = Aergia.find_loop_in_locals(frame.f_locals)
+ if loop:
+ return loop
frame = frame.f_back
return None
@staticmethod
- def find_runner_in_locals(locals_dict):
+ def find_loop_in_locals(locals_dict):
'''Given a dictionary of local variables for a stack frame,
- retrieves the asyncio runner object, if there is one.'''
+ retrieves the asyncio loop object, if there is one.
+
+ This function should work on Windows, but this is dubious because
+ I don't have a system to test with.'''
for val in locals_dict.values():
- if type(val).__name__ == 'Runner' and \
- val.__class__.__module__ == 'asyncio.runners':
+ if isinstance(val, asyncio.AbstractEventLoop):
return val
return None
@staticmethod
- def get_frames_from_runners(runners):
- '''Given RUNNERS, returns a flat list of tasks.'''
+ def get_frames_from_loops(loops):
+ '''Given LOOPS, returns a flat list of tasks.'''
return [
- task for runner in runners
- for task in Aergia.get_idle_task_frames(runner._loop)
+ task for loop in loops
+ for task in Aergia.get_idle_task_frames(loop)
]
@staticmethod
@@ -262,6 +266,7 @@ class Aergia(object):
@staticmethod
def should_trace(filename):
'''Returns FALSE if filename is uninteresting to the user.'''
+ # return True
# FIXME Assume GuixSD. Makes filtering easy
if '/gnu/store' in filename:
return False