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

bpo-30098: Adds verbose error to asyncio.ensure_future #1170

Merged
merged 2 commits into from
Apr 21, 2017

Conversation

crenwick
Copy link
Contributor

Despite the shy mention in the docs, it was not clear to me that the future returned from asyncio.run_coroutine_threadsafe is not compatible with asyncio.ensure_future (and other asyncio functions), and it took me a fair amount of frustration and source-code-digging to figure out what was going on.

To avoid this confusion for other users, I think that a verbose TypeError warning when a concurrent.futures.Future object is passed into asyncio.ensure_future would be very helpful.

Few questions:

  • Is there a better way to check if the obj is a concurrent.futures.Future?
  • Is the language in the TypeError ok? I tried to make it compatible with the default TypeError.

Let me know what you think! Thanks!

Adds a verbose type error when a concurrent.futures.Future object is
passed into the asyncio.ensure_future function.
@mention-bot
Copy link

@crenwick, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1st1, @bitdancer and @Mariatta to be potential reviewers.

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@Mariatta
Copy link
Member

Hi, code changes like this aren't considered trivial. Please create an issue in the bug tracker https://bugs.python.org

Thanks :)

@crenwick
Copy link
Contributor Author

Filed! (I also signed the CLA.)

@Mariatta Mariatta changed the title Adds verbose error to asyncio.ensure_future bpo-30098: Adds verbose error to asyncio.ensure_future Apr 18, 2017
@Mariatta
Copy link
Member

Thanks :) I changed the title to include the bpo-#

The CLA can take one business day before it gets updated to your account.

@1st1 1st1 self-requested a review April 18, 2017 22:52
@1st1 1st1 self-assigned this Apr 18, 2017
Removes the verbose error that is raised only when a
concurrent.futures.Future object is passed into `ensure_future`, and
instead changes the language of the already existing TypeError to read
`asyncio.Future` instead of just `Future`
@1st1
Copy link
Member

1st1 commented Apr 20, 2017

@crenwick Did you update your bpo profile with your GH username?

@crenwick
Copy link
Contributor Author

@1st1 Yup!

@Mariatta
Copy link
Member

Thanks @crenwick and congrats for your first contribution to CPython 🎉

I will backport this later today.

Mariatta added a commit that referenced this pull request Apr 22, 2017
Mariatta added a commit that referenced this pull request Apr 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants