-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
asyncio: We should prohibit setting a ProcessPoolExecutor in with set_default_executor #78256
Comments
I've had a few conversations with people who were confused that asyncio starts to behave weirdly when a ProcessPoolExecutor is set as the default one. We don't really test that asyncio's built-in functionality (like DNS resolving) works well with a process-pool, which leads to bug reports like [1]. Third-party libraries also always assume that the loop is always configured to use the ThreadPoolExecutor (as it is by default), and also don't even test against ProcessPool. My idea here would be to deprecate setting ProcessPoolExecutor as a default one in 3.8 and prohibit that in 3.9. Guido, Andrew, what do you think? |
Yeah, that's a good idea. It was never meant for a ProcessPoolExecutor. We should warn against this in the docs right away (and backport the warning to all previous versions that have set_executor). I also support non-silent deprecation in 3.8. |
Great! Thanks for the quick reply, Guido. |
I think we'll only allow instances of c.f.ThreadPoolExecutor (and its subclasses) to be passed to set_default_executor. That's a more robust check than just guarding against ProcessPoolExecutor. |
Of course, that's what I meant. |
I suggest to only reject ProcessPoolExecutor, instead of having a very specific test on ThreadPoolExecutor which might fail with funky but valid thread executor. |
I disagree. Other than subclasses of thread executor, what are you going to On Wed, Jul 11, 2018 at 7:34 AM STINNER Victor <report@bugs.python.org>
-- |
I don't see why asyncio should prevent people to experiment their own custom executor. You can imagine a custom "green executor" which inherit from Executor but uses its own black magic like greenlet. People like to do crazy things to implement asynchronous programming :-) |
Because asyncio and its ecosystem is built around the fact that the default executor is a ThreadPoolExecutor. asyncio users are free to:
Mind that (2) also covers exotic use cases like using greenlets under the hood (although I don't think it's possible), as long as they subclass ThreadPoolExecutor. My plan so far:
|
Agree, restricting to ThreadPoolExecutor sounds reasonable. A custom executor may have the same problem as ProcessPoolExecutor. Moreover it can work under same scenarios but crash with other third-party libs. |
Elvis Pranskevichus: well done, your first PR was already good to be merged ;-) |
I think this issue is related to the problem in https://bugs.python.org/issue36281 If it indeed is the case, then the fix proposed here and implemented in 22d2508 won't really help. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: