summaryrefslogtreecommitdiff
path: root/aergia
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-07-22 21:01:35 -0600
committerbd <bdunahu@operationnull.com>2025-07-22 21:01:35 -0600
commit02ca06b3e835b34b577caf8931abe7c3786a7d87 (patch)
tree9e40004a0e3173e18c822ad64c8b331be060bc9f /aergia
parent9cb17e4063b2710e0fbfde944e8a26b4a4ae38e4 (diff)
Add imperfect logic to include async generators in profiled frames
Diffstat (limited to 'aergia')
-rwxr-xr-xaergia/aergia.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/aergia/aergia.py b/aergia/aergia.py
index d14520a..6f43f2e 100755
--- a/aergia/aergia.py
+++ b/aergia/aergia.py
@@ -53,6 +53,7 @@ import sys
import threading
import time
import traceback
+import inspect
orig_thread_join = threading.Thread.join
@@ -247,6 +248,15 @@ class Aergia(object):
f = Aergia._get_deepest_traceable_frame(coro)
if f:
idle.append(f)
+
+ # handle async generators
+ # ideally, we would access these from _get_deepest_traceable_frame
+ # doing it this way causes us to assign generator time to the
+ # coroutine that called this generator in _get_deepest_traceable_frame
+ for ag in loop._asyncgens:
+ f = getattr(ag, 'ag_frame', None)
+ if f and Aergia._should_trace(f.f_code.co_filename):
+ idle.append(f)
return idle
@staticmethod