Skip to content

Commit b0995a9

Browse files
committed
[3.7] bpo-43293: Doc: move note about GIL to top of threading module (pythonGH-24622)
The note about the GIL was buried pretty deep in the threading documentation, and this made it hard for first time users to discover why their attempts at using threading to parallelizing their application did not work. In this commit, the note is moved to the top of the module documention for visibility.. (cherry picked from commit 32181be) Co-authored-by: Guanzhong Chen <[email protected]>
1 parent 37ba753 commit b0995a9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Doc/library/threading.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ level :mod:`_thread` module. See also the :mod:`queue` module.
2121
supported by this module.
2222

2323

24+
.. impl-detail::
25+
26+
In CPython, due to the :term:`Global Interpreter Lock`, only one thread
27+
can execute Python code at once (even though certain performance-oriented
28+
libraries might overcome this limitation).
29+
If you want your application to make better use of the computational
30+
resources of multi-core machines, you are advised to use
31+
:mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`.
32+
However, threading is still an appropriate model if you want to run
33+
multiple I/O-bound tasks simultaneously.
34+
35+
2436
This module defines the following functions:
2537

2638

@@ -323,18 +335,6 @@ since it is impossible to detect the termination of alien threads.
323335
property instead.
324336

325337

326-
.. impl-detail::
327-
328-
In CPython, due to the :term:`Global Interpreter Lock`, only one thread
329-
can execute Python code at once (even though certain performance-oriented
330-
libraries might overcome this limitation).
331-
If you want your application to make better use of the computational
332-
resources of multi-core machines, you are advised to use
333-
:mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`.
334-
However, threading is still an appropriate model if you want to run
335-
multiple I/O-bound tasks simultaneously.
336-
337-
338338
.. _lock-objects:
339339

340340
Lock Objects

0 commit comments

Comments
 (0)