diff options
author | Yury Selivanov <yury@magic.io> | 2016-10-05 23:32:49 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-10-05 23:32:49 (GMT) |
commit | 8dc3e438398046c6bb989e038cd08280aa356982 (patch) | |
tree | 84019478ef27a0b2273cbda25d13de72f1dcfee2 /Lib/asyncio | |
parent | 0de3de6cbfe034654dc03f3808de0c25e28a0c38 (diff) | |
download | cpython-8dc3e438398046c6bb989e038cd08280aa356982.zip cpython-8dc3e438398046c6bb989e038cd08280aa356982.tar.gz cpython-8dc3e438398046c6bb989e038cd08280aa356982.tar.bz2 |
Issue #28372: Fix asyncio to support formatting of non-python coroutines
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/coroutines.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index 5cecc76..1db7030 100644 --- a/Lib/asyncio/coroutines.py +++ b/Lib/asyncio/coroutines.py @@ -261,6 +261,25 @@ def iscoroutine(obj): def _format_coroutine(coro): assert iscoroutine(coro) + if not hasattr(coro, 'cr_code') and not hasattr(coro, 'gi_code'): + # Most likely a Cython coroutine. + coro_name = getattr(coro, '__qualname__', coro.__name__) + coro_name = '{}()'.format(coro_name) + + running = False + try: + running = coro.cr_running + except AttributeError: + try: + running = coro.gi_running + except AttributeError: + pass + + if running: + return '{} running'.format(coro_name) + else: + return coro_name + coro_name = None if isinstance(coro, CoroWrapper): func = coro.func |