From 2be1331b97e2028a59087ad229cc71a88b72dec6 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 29 Jul 2025 22:57:21 -0400 Subject: Fix bug where unstarted tasks would attribute time to coro decl --- aergia/aergia.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'aergia') diff --git a/aergia/aergia.py b/aergia/aergia.py index b99f06d..efc68e2 100755 --- a/aergia/aergia.py +++ b/aergia/aergia.py @@ -54,6 +54,8 @@ import threading import time import traceback +import pprint + orig_thread_join = threading.Thread.join @@ -205,7 +207,6 @@ class Aergia(object): if isinstance(loop, asyncio.AbstractEventLoop): return loop else: - # print(frame.f_code.co_name) frame = frame.f_back return None @@ -271,8 +272,16 @@ class Aergia(object): idle = [] current = asyncio.current_task(loop) for task in asyncio.all_tasks(loop): + # the task is not idle if task == current: continue + # the task hasn't even run yet + # assumes that all started tasks are sitting at an await + # statement. + # if this isn't the case, the associated coroutine will + # be 'waiting' on the coroutine declaration. No! Bad! + if getattr(task.get_coro(), 'cr_await', None) is None: + continue coro = task.get_coro() if coro: f = Aergia._get_deepest_traceable_frame(coro) -- cgit v1.2.3