Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-100112: avoid using iterable coroutines in asyncio internally #100128

Merged
merged 5 commits into from
Mar 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add wrapper
  • Loading branch information
kumaraditya303 committed Mar 10, 2023
commit a6492e9149ca871ecf1ae7738828c48aeb43d90c
10 changes: 5 additions & 5 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from . import exceptions
from . import futures
from . import timeouts
from .coroutines import _is_coroutine

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


@types.coroutine
def _wrap_awaitable(awaitable):
async def _wrap_awaitable(awaitable):
"""Helper for asyncio.ensure_future().

Wraps awaitable (an object with __await__) into a coroutine
that will later be wrapped in a Task by ensure_future().
"""
return (yield from awaitable.__await__())

_wrap_awaitable._is_coroutine = _is_coroutine
@types.coroutine
def wrapper(awaitable):
return (yield from awaitable.__await__())

return await wrapper(awaitable)

class _GatheringFuture(futures.Future):
"""Helper for gather().
Expand Down