mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
Issue #28372: Fix asyncio to support formatting of non-python coroutines
This commit is contained in:
parent
0de3de6cbf
commit
8dc3e43839
3 changed files with 55 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue