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-34014: Added support of contextvars for BaseEventLoop.run_in_executor #9688

Closed
wants to merge 8 commits into from

Conversation

hellysmile
Copy link
Contributor

@hellysmile hellysmile commented Oct 3, 2018

An updated version of #8035

according to latest discussion on https://bugs.python.org/issue34014

If proposed solution looks good I'll start updating related docs changes

https://bugs.python.org/issue34014

Copy link
Member

@1st1 1st1 left a comment

Choose a reason for hiding this comment

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

[Blocking this to prevent accidental merge.]

As per the bpo discussion: our goal is to provide a new API for working with threadpools and processpools. If we end up having their design ready in a few months we might want to revisit this PR. If not, we'll likely merge this PR as is.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@hellysmile
Copy link
Contributor Author

@1st1 thanks for the update!

Is there any PEP/API spec/ideas available?

@csabella csabella requested review from 1st1 and asvetlov and removed request for asvetlov May 31, 2019 11:36
@hellysmile
Copy link
Contributor Author

master was just merged

@hellysmile
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@1st1: please review the changes made to this pull request.

@1st1
Copy link
Member

1st1 commented Oct 20, 2019

I'm still not sure about this -- we can't make contextvars work with process pools. :( Need to design a new API for 3.9. You can champion that; first we need to start a discussion. We'll need to assess the current situation, what are the alternatives (curio, trio, twisted), and what's the best possible api we can design for asyncio given its constraints.

@hellysmile
Copy link
Contributor Author

hellysmile commented Oct 21, 2019

@1st1 seems using something rather than ThreadPoolExecutor will be prohibited in 3.9

https://github.com/python/cpython/blob/master/Lib/asyncio/base_events.py#L811

what about to restrict same way using not ThreadPoolExecutor instances as executor argument in run_in_executor

and silently apply propagation of contextvars

then we can point this changes to Python 3.9

@1st1
Copy link
Member

1st1 commented Oct 21, 2019

and silently apply propagation of contextvars

Yeah, that's another problem, as we didn't do so in 3.7/3.8.

@asvetlov what do you think?

@asvetlov
Copy link
Contributor

process pool executor is forbidden as default because things like DNS resolving doesn't work with it IIRC.
Passing explicit ProcessPoolExecutor into run_in_executor() is still supported.

Sorry, I don't follow what the proposal is? Please elaborate silently apply propagation of contextvars part

gjoseph92 added a commit to gjoseph92/distributed that referenced this pull request Oct 27, 2021
Helps with setting the current client in worker while deserializing. Implementation referenced from python/cpython#9688
gjoseph92 added a commit to gjoseph92/distributed that referenced this pull request Nov 1, 2021
Helps with setting the current client in worker while deserializing. Implementation referenced from python/cpython#9688
@NargiT
Copy link

NargiT commented Feb 16, 2022

any news about this ?

@asvetlov asvetlov closed this Mar 23, 2022
@NargiT
Copy link

NargiT commented Mar 24, 2022

@asvetlov is there an alternative to this ?

@asvetlov
Copy link
Contributor

@asvetlov is there an alternative to this ?

Take a look at asyncio.to_thread()

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

Successfully merging this pull request may close these issues.

7 participants