Skip to content

gh-145912: Clarify the note about the GIL in the asyncio.to_thread() docs - #162887

Open
ngoldbaum wants to merge 2 commits into
python:mainfrom
ngoldbaum:asyncio-gil-wording
Open

ngoldbaum wants to merge 2 commits into
python:mainfrom
ngoldbaum:asyncio-gil-wording

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

This note dates from when asyncio.to_thread() was added in 3.9 (GH-20143), before the free-threaded build existed. Its current content is confusing now that the free-threaded build exists.

The new wording explains that with the GIL enabled, a CPU-bound function in a thread slows the event loop down but does not block it. It also mentions the free-threaded build, where two threads don't have to take turns on a CPU-bound task.

Also see #162886, which this conflicts with. I'll handle dealing with the conflicts.

@read-the-docs-community

read-the-docs-community Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #36275822 | 📁 Comparing 92e9309 against main (114f465)

  🔍 Preview build  

1 file changed
± library/asyncio-task.html

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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant