diff options
| author | bd <bdunahu@operationnull.com> | 2025-07-26 21:31:52 -0600 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-07-26 21:31:52 -0600 |
| commit | 2307761116ce849f45fe92d1e08c647a824a2273 (patch) | |
| tree | ac466f1840957dab5ae9fbd4f56783ae1717899f /aergia | |
| parent | 7c6be83c05f27d27ff6d0ef62622e8ae12ce1504 (diff) | |
Profile the current task as well
Diffstat (limited to 'aergia')
| -rwxr-xr-x | aergia/aergia.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/aergia/aergia.py b/aergia/aergia.py index 6f43f2e..28e8d7a 100755 --- a/aergia/aergia.py +++ b/aergia/aergia.py @@ -53,7 +53,6 @@ import sys import threading import time import traceback -import inspect orig_thread_join = threading.Thread.join @@ -110,7 +109,6 @@ class Aergia(object): in `Aergia._get_idle_task_frames'. The TimerHandler object otherwise does not keep track of a _source_traceback. ''' - os.environ["PYTHONASYNCIODEBUG"] = "1" signal.signal(signal.SIGALRM, Aergia._idle_signal_handler) signal.setitimer(signal.ITIMER_REAL, @@ -239,10 +237,7 @@ class Aergia(object): '''Given an asyncio event loop, returns the list of idle task frames. A task is considered 'idle' if it is not currently executing.''' idle = [] - current = asyncio.current_task(loop) for task in asyncio.all_tasks(loop): - if task == current: - continue coro = task.get_coro() if coro: f = Aergia._get_deepest_traceable_frame(coro) @@ -316,12 +311,19 @@ if __name__ == "__main__": metavar='', type=float, default=0.01) + parser.add_argument('-d', '--debug', + help='Turn on debug information for the event loop.', + metavar='', + type=bool, + default=False) parser.add_argument('script', help='A python script to run.') parser.add_argument('s_args', nargs=argparse.REMAINDER, help='python script args') args = parser.parse_args() sys.argv = [args.script] + args.s_args + if args.debug: + os.environ["PYTHONASYNCIODEBUG"] = "1" try: with open(args.script, 'r', encoding='utf-8') as fp: code = compile(fp.read(), args.script, "exec") |
