Skip to content

Commit a6fe31d

Browse files
committed
Fix patched _format_coroutine to support Cython generators
1 parent d345ec3 commit a6fe31d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

uvloop/_patch.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,23 @@
44

55

66
def _format_coroutine(coro):
7-
if asyncio.iscoroutine(coro) and not hasattr(coro, 'cr_code'):
7+
if asyncio.iscoroutine(coro) \
8+
and not hasattr(coro, 'cr_code') \
9+
and not hasattr(coro, 'gi_code'):
10+
811
# Most likely a Cython coroutine
912
coro_name = '{}()'.format(coro.__qualname__ or coro.__name__)
10-
if coro.cr_running:
13+
14+
running = False
15+
try:
16+
running = coro.cr_running
17+
except AttributeError:
18+
try:
19+
running = coro.gi_running
20+
except AttributeError:
21+
pass
22+
23+
if running:
1124
return '{} running'.format(coro_name)
1225
else:
1326
return coro_name

0 commit comments

Comments
 (0)