Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc6accc

Browse files
committed
Remove outdated statements about threading and imports.
1 parent 79341e7 commit fc6accc

2 files changed

Lines changed: 1 addition & 27 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ processes:
120120
print(q.get()) # prints "[42, None, 'hello']"
121121
p.join()
122122

123-
Queues are thread and process safe, but note that they must never
124-
be instantiated as a side effect of importing a module: this can lead
125-
to a deadlock! (see :ref:`threaded-imports`)
123+
Queues are thread and process safe.
126124

127125
**Pipes**
128126

Doc/library/threading.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -996,27 +996,3 @@ is equivalent to::
996996
Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`,
997997
:class:`Semaphore`, and :class:`BoundedSemaphore` objects may be used as
998998
:keyword:`with` statement context managers.
999-
1000-
1001-
.. _threaded-imports:
1002-
1003-
Importing in threaded code
1004-
--------------------------
1005-
1006-
While the import machinery is thread-safe, there are two key restrictions on
1007-
threaded imports due to inherent limitations in the way that thread-safety is
1008-
provided:
1009-
1010-
* Firstly, other than in the main module, an import should not have the
1011-
side effect of spawning a new thread and then waiting for that thread in
1012-
any way. Failing to abide by this restriction can lead to a deadlock if
1013-
the spawned thread directly or indirectly attempts to import a module.
1014-
* Secondly, all import attempts must be completed before the interpreter
1015-
starts shutting itself down. This can be most easily achieved by only
1016-
performing imports from non-daemon threads created through the threading
1017-
module. Daemon threads and threads created directly with the thread
1018-
module will require some other form of synchronization to ensure they do
1019-
not attempt imports after system shutdown has commenced. Failure to
1020-
abide by this restriction will lead to intermittent exceptions and
1021-
crashes during interpreter shutdown (as the late imports attempt to
1022-
access machinery which is no longer in a valid state).

0 commit comments

Comments
 (0)