diff options
| author | bd <bdunahu@operationnull.com> | 2025-07-27 18:17:28 -0600 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-07-27 18:17:28 -0600 |
| commit | 9691ed64bd22820199275492792fa0a6b50bc95f (patch) | |
| tree | 4a8b426c2224b26d68ef43ccf15f3f931837f609 /aergia/aergia.py | |
| parent | b506d6fc0da5d676c05b8db03ebab7f7b2dfcf48 (diff) | |
Fix bug where duplicate frames would get added (current tasks)
Diffstat (limited to 'aergia/aergia.py')
| -rwxr-xr-x | aergia/aergia.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/aergia/aergia.py b/aergia/aergia.py index d3c525d..be7da35 100755 --- a/aergia/aergia.py +++ b/aergia/aergia.py @@ -157,13 +157,13 @@ class Aergia(object): @staticmethod def _idle_signal_handler(sig, frame): '''Obtains and records which lines are currently being waited on.''' - keys = Aergia._compute_frames_to_record(frame) + keys = Aergia._compute_frames_to_record() for key in keys: Aergia.samples[Aergia._frame_to_tuple(key)] += 1 Aergia.total_samples += 1 @staticmethod - def _compute_frames_to_record(frame): + def _compute_frames_to_record(): '''Collects all stack frames which are currently being awaited on during a given timestamp, as well as those which are currently executing. @@ -179,7 +179,7 @@ class Aergia(object): frames = Aergia._get_frames_from_loops(loops) # current running frames if Aergia.do_profile_current: - frames += Aergia._get_frames_from_threads(frame) + frames += Aergia._get_frames_from_threads() return frames @staticmethod @@ -219,27 +219,26 @@ class Aergia(object): ] @staticmethod - def _get_frames_from_threads(frame): - frames = [frame] - frames += [sys._current_frames().get(t.ident, None) + def _get_frames_from_threads(): + frames = [sys._current_frames().get(t.ident, None) for t in threading.enumerate()] # process frames to remove those we do not track new_frames = [] for f in frames: if f is None: continue - fname = frame.f_code.co_filename + fname = f.f_code.co_filename while not Aergia._should_trace(fname): # walk the stack backwards until we hit a frame that is one # we should trace. - if frame: - frame = frame.f_back + if f: + f = f.f_back else: break - if frame: - fname = frame.f_code.co_filename - if frame: - new_frames.append(frame) + if f: + fname = f.f_code.co_filename + if f: + new_frames.append(f) return new_frames @staticmethod |
