Repository navigation
Conversation
Documentation build overview
41 files changed ·
|
Documentation build overview
|
willingc
left a comment
There was a problem hiding this comment.
@ngoldbaum This draft is off to a fabulous start. A few suggestions to ground readers before diving into specifics. Thank you!
| :class:`concurrent.futures.ThreadPoolExecutor`. Each thread runs its own | ||
| function :term:`concurrently <concurrency>` with the others. |
There was a problem hiding this comment.
| :class:`concurrent.futures.ThreadPoolExecutor`. Each thread runs its own | |
| function :term:`concurrently <concurrency>` with the others. | |
| :class:`concurrent.futures.ThreadPoolExecutor`. Each thread works :term:`concurrently <concurrency>` with the others. |
| appear to freeze because it is doing other work and cannot check for user | ||
| input. When a function makes its caller wait for an arbitrarily long time, it |
There was a problem hiding this comment.
| appear to freeze because it is doing other work and cannot check for user | |
| input. When a function makes its caller wait for an arbitrarily long time, it | |
| appear to freeze while doing other work and unable to check for user | |
| input. When a function makes its caller wait for an arbitrarily long time, it |
| with ``async`` and ``await``; threads do it for ordinary functions that may | ||
| block. | ||
|
|
||
| Threads can also divide work between CPU cores. In the default build of |
There was a problem hiding this comment.
A new heading would be helpful here. The first two paragraphs are introductory and address basic terms. This paragraph starts the difference between traditional GIL version and free-threaded build.
Subheadings for Sharing modules and globals, Sharing objects, and Thread safety would be helpful for scanning and grounding the reader's context.
| cost? | ||
| - How do I coordinate work between the threads in my program? | ||
|
|
||
| This HOWTO is for Python programmers who are new to writing multi-threaded |
There was a problem hiding this comment.
I would add a heading here. "Writing multi-threaded code" or something similar.
| classes, and it does not assume any experience with threads. | ||
|
|
||
| Below, we describe several strategies for making Python code | ||
| thread-safe. Working with threads requires a trade-off between safety, |
There was a problem hiding this comment.
Consider bolding the trade-offs: safety, performance, code simplicity
|
Thanks @willingc I think I integrated your comments. Instead of bolding things for emphasis, I linked to a table that illustrates the trade-offs. I also added an outline for a "why should I use threads" section, which I think this needs and was missing. I also opened two other PRs related to this work:
Once those are reviewed separately I'll update this to link to text from those PRs where appropriate. I expect there to be more general docs improvements spawned by this work. I'll be at the docs team meeting tomorrow to get a temperature check on this approach. |
Part of #145912.
Adds a practical introduction to writing correct multi-threaded Python code, covering race conditions, sharing data, and coordinating threads on both default and free-threaded builds.
Opening as a draft for feedback on the scope and structure and to get a docs preview; several sections are still outlines.