@@ -996,27 +996,3 @@ is equivalent to::
996996Currently, :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