Skip to content

Conversation

@anordin95
Copy link
Contributor

@anordin95 anordin95 commented Aug 27, 2025

Right now, I think the article creates a logical gap that has the potential to confuse readers.

The "in each thread" part implies there can be multiple event loops (via multithreading) in the same memory space. It's quite natural to then wonder how tasks will be associated with event loops when there are multiple event loops to choose from. And how you, the user, could manage which loop a task is assigned to. I see that as an easy way for the reader to be left in the dark, wondering.

I see two potential solutions. One is clarifying how tasks and event loops are paired in a multithreaded environment. The other, not mentioning threads at all. I don't feel that strongly either way. However, I do feel strongly that if we mention threads we need to explain how threads and multiple event loops interact.

Approach 1

:mod:!asyncio automatically associates tasks with the event loop for you.
Typically there's only one event loop, so that's quite straightforward.
It's uncommon, but some applications use multithreading and :mod:!asyncio
together, where there's one event loop per thread, stored in thread-local
storage.

Approach 2

No mention of threads. See the suggested changes in this PR.



📚 Documentation preview 📚: https://cpython-previews--138200.org.readthedocs.build/

@anordin95
Copy link
Contributor Author

@ZeroIntensity, I think you may like the proposed changes. It removes any mention of threading and I think improves clarity. If you have the time, I would appreciate a review :)

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

I'm fine with this wording, but I think the final decision should be up to Kumar.

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Nov 24, 2025
@ZeroIntensity
Copy link
Member

Ok, I'm going to merge this one. Kumar, if you have any strong objections to the wording, please feel free to send a revert or an update.

@ZeroIntensity ZeroIntensity enabled auto-merge (squash) November 24, 2025 14:05
@ZeroIntensity ZeroIntensity merged commit a4f4225 into python:main Nov 24, 2025
31 of 32 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Nov 24, 2025
@miss-islington-app
Copy link

Thanks @anordin95 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app
Copy link

Sorry, @anordin95 and @ZeroIntensity, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker a4f422521337d3310b71bb081c195e64c2035bbb 3.14

@miss-islington-app
Copy link

Sorry, @anordin95 and @ZeroIntensity, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker a4f422521337d3310b71bb081c195e64c2035bbb 3.13

@ZeroIntensity
Copy link
Member

@anordin95 Would you like to try handling the backports?

@bedevere-app
Copy link

bedevere-app bot commented Nov 25, 2025

GH-141928 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Nov 25, 2025
anordin95 added a commit to anordin95/cpython that referenced this pull request Nov 25, 2025
@bedevere-app
Copy link

bedevere-app bot commented Nov 25, 2025

GH-141929 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 25, 2025
@anordin95
Copy link
Contributor Author

anordin95 commented Nov 25, 2025

@ZeroIntensity - Mhm 👍

3.14: #141928

3.13: #141929

ZeroIntensity pushed a commit that referenced this pull request Nov 25, 2025
… (GH-141928)

gh-138199: Address potential confusion regarding threading in the `asyncio` HOWTO (GH-138200)

(cherry picked from commit a4f4225)
ZeroIntensity pushed a commit that referenced this pull request Nov 25, 2025
… (GH-141929)

gh-138199: Address potential confusion regarding threading in the `asyncio` HOWTO (GH-138200)

(cherry picked from commit a4f4225)
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
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 skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants