Skip to content

Conversation

@1st1
Copy link
Member

@1st1 1st1 commented Sep 24, 2018

@1st1
Copy link
Member Author

1st1 commented Sep 24, 2018

cc @elprans


If any awaitable in *aws* is a coroutine, it is automatically
scheduled as a Task.
scheduled as a Task. Although passing coroutines objects to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop "although".

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat example :)

@1st1
Copy link
Member Author

1st1 commented Sep 25, 2018

Neat example :)

What do you think about deprecating the current wait() design and fixing it in a couple releases?

@asvetlov
Copy link
Contributor

I'd like to deprecate passing regular coroutines into gather() as well

@asvetlov
Copy link
Contributor

Creating a task if a coroutine is passed to a function is too... implicit.

@1st1
Copy link
Member Author

1st1 commented Sep 25, 2018

I'd like to deprecate passing regular coroutines into gather() as well

Radical :) I agree, it's confusing. Although maybe we can keep gather() as is and just recommend people to use TaskGroups instead. I believe gather() is way more heavily used than wait().

@1st1 1st1 merged commit 996859a into python:master Sep 25, 2018
@miss-islington
Copy link
Contributor

Thanks @1st1 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@1st1 1st1 deleted the fix_wait_doc branch September 25, 2018 18:51
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 25, 2018
@bedevere-bot
Copy link

GH-9577 is a backport of this pull request to the 3.7 branch.

@asvetlov
Copy link
Contributor

Yes, people prefer gather() to wait().
I'm ok with not changing gather() but hiding it behind task groups in the documentation.
On the other hand, depreciation is not harmful. We can do it slowly starting from PendingDeprecationWarning

miss-islington added a commit that referenced this pull request Sep 25, 2018
…ng. (GH-9543)

(cherry picked from commit 996859a)

Co-authored-by: Yury Selivanov <[email protected]>
@1st1
Copy link
Member Author

1st1 commented Sep 25, 2018

I'm ok with not changing gather() but hiding it behind task groups in the documentation.

Yep!

On the other hand, depreciation is not harmful. We can do it slowly starting from PendingDeprecationWarning

It can be very annoying in large codebases though. I think it's a good idea to use PendingDeprecationWarning for wait() in 3.8.

@asvetlov
Copy link
Contributor

I think it's a good idea to use PendingDeprecationWarning for wait() in 3.8.

+1

carmenbianca added a commit to carmenbianca/python-prompt-toolkit that referenced this pull request Nov 22, 2020
Under some circumstances (see
<xonsh/xonsh#3907>) a DeprecationWarning would
be printed. This is because of passing coroutine objects directly to
asyncio.wait(), which is confusing behaviour that has been deprecated.

<python/cpython#9543> gives information on how
to refactor code that uses the deprecated method.

Signed-off-by: Carmen Bianca Bakker <[email protected]>
jonathanslenders pushed a commit to prompt-toolkit/python-prompt-toolkit that referenced this pull request Dec 3, 2020
* Prevent asyncio DeprecationWarning

Under some circumstances (see
<xonsh/xonsh#3907>) a DeprecationWarning would
be printed. This is because of passing coroutine objects directly to
asyncio.wait(), which is confusing behaviour that has been deprecated.

<python/cpython#9543> gives information on how
to refactor code that uses the deprecated method.

Signed-off-by: Carmen Bianca Bakker <[email protected]>
@VasiliPupkin256
Copy link

This makes a simple timeouted wait even more complicated than it was already. You should consider adding timeout to wait() functions then.

What we had:

await asyncio.wait({event.wait()}, timeout)

Now we have two options:

await asyncio.wait({asyncio.create_task(event.wait())}, timeout)

or

with contextlib.suppress(asyncio.TimeoutError):
    await asyncio.wait_for(event.wait(), timeout)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants