Skip to content

Commit a6492e9

Browse files
add wrapper
1 parent 2999e02 commit a6492e9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/asyncio/tasks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from . import exceptions
2626
from . import futures
2727
from . import timeouts
28-
from .coroutines import _is_coroutine
2928

3029
# Helper to generate new task names
3130
# This uses itertools.count() instead of a "+= 1" operation because the latter
@@ -654,17 +653,18 @@ def ensure_future(coro_or_future, *, loop=None):
654653
raise
655654

656655

657-
@types.coroutine
658-
def _wrap_awaitable(awaitable):
656+
async def _wrap_awaitable(awaitable):
659657
"""Helper for asyncio.ensure_future().
660658
661659
Wraps awaitable (an object with __await__) into a coroutine
662660
that will later be wrapped in a Task by ensure_future().
663661
"""
664-
return (yield from awaitable.__await__())
665662

666-
_wrap_awaitable._is_coroutine = _is_coroutine
663+
@types.coroutine
664+
def wrapper(awaitable):
665+
return (yield from awaitable.__await__())
667666

667+
return await wrapper(awaitable)
668668

669669
class _GatheringFuture(futures.Future):
670670
"""Helper for gather().

0 commit comments

Comments
 (0)