diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-03-02 13:03:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 13:03:50 (GMT) |
commit | 43932dc1eaf36d75b2ee0420d8be747001315c26 (patch) | |
tree | 2a830592594f021120056cb5daf0667f5a1bb42e /Lib/asyncio | |
parent | f28b0c74e54a133cb0287b4297af67d0d7c14d6e (diff) | |
download | cpython-43932dc1eaf36d75b2ee0420d8be747001315c26.zip cpython-43932dc1eaf36d75b2ee0420d8be747001315c26.tar.gz cpython-43932dc1eaf36d75b2ee0420d8be747001315c26.tar.bz2 |
bpo-39764: Make Task.get_stack accept ag_frame (GH-18669)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 4482337decdbd0c6e2150346a68b3616bda664aa)
Co-authored-by: Lidi Zheng <scallopsky@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/base_tasks.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/asyncio/base_tasks.py b/Lib/asyncio/base_tasks.py index e2da462..09bb171 100644 --- a/Lib/asyncio/base_tasks.py +++ b/Lib/asyncio/base_tasks.py @@ -24,11 +24,18 @@ def _task_repr_info(task): def _task_get_stack(task, limit): frames = [] - try: - # 'async def' coroutines + if hasattr(task._coro, 'cr_frame'): + # case 1: 'async def' coroutines f = task._coro.cr_frame - except AttributeError: + elif hasattr(task._coro, 'gi_frame'): + # case 2: legacy coroutines f = task._coro.gi_frame + elif hasattr(task._coro, 'ag_frame'): + # case 3: async generators + f = task._coro.ag_frame + else: + # case 4: unknown objects + f = None if f is not None: while f is not None: if limit is not None: |