gh-85299: Add note warning about entry point guard for asyncio example
#85299
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor
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.
Okay, I am beginning to understand the issue. It's due to the process pool example. If I comment out this block of code from the example:
# 3. Run in a custom process pool:
with concurrent.futures.ProcessPoolExecutor() as pool:
result = await loop.run_in_executor(
pool, cpu_bound)
print('custom process pool', result)
everything is fine. If I leave that in the run (on macOS) fails spectacularly with a RuntimeError that has many lines of traceback, then a multi-line error message, and then more traceback lines. Adding the __main__ guard makes this go away.
I presume that's one of the many reasons not to use ProcessPoolExecutor. :-(
I propose to rephrase the note to mention the platform and just link to https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods, not to the change note.
Thanks @slateny for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. 🐍🍒⛏🤖
Thanks @slateny for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. 🐍🍒⛏🤖
GH-98334 is a backport of this pull request to the 3.11 branch.
Let’s see if we can backport this.
GH-98335 is a backport of this pull request to the 3.10 branch.