summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-02-23 23:25:26 +0000
committerGeorg Brandl <georg@python.org>2008-02-23 23:25:26 +0000
commitf1699cd4c1b475a3e583c8975317df06907dcf8b (patch)
treec94145b485cd361a0671250594a8d39b87b70bd1
parentebcfd11c164d7783de183e40217a5fd39a2c891e (diff)
downloadcpython-git-f1699cd4c1b475a3e583c8975317df06907dcf8b.tar.gz
Document import ./. threading issues. #1720705.
-rw-r--r--Doc/library/thread.rst6
-rw-r--r--Doc/library/threading.rst7
2 files changed, 12 insertions, 1 deletions
diff --git a/Doc/library/thread.rst b/Doc/library/thread.rst
index b0e55ea275..968ebf13b4 100644
--- a/Doc/library/thread.rst
+++ b/Doc/library/thread.rst
@@ -150,6 +150,11 @@ In addition to these methods, lock objects can also be used via the
exception will be received by an arbitrary thread. (When the :mod:`signal`
module is available, interrupts always go to the main thread.)
+* The import machinery is not thread safe. In general, an import may not
+ have the side effect of importing a module, and only the main thread
+ should import modules. Imports within or caused by a thread other than
+ the main thread isn't safe.
+
* Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is
equivalent to calling :func:`exit`.
@@ -170,4 +175,3 @@ In addition to these methods, lock objects can also be used via the
* When the main thread exits, it does not do any of its usual cleanup (except
that :keyword:`try` ... :keyword:`finally` clauses are honored), and the
standard I/O files are not flushed.
-
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 077ae0119c..73ede7b6c5 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -562,6 +562,13 @@ the :meth:`setDaemon` method and retrieved with the :meth:`isDaemon` method.
There is a "main thread" object; this corresponds to the initial thread of
control in the Python program. It is not a daemon thread.
+.. warning::
+
+ The import machinery is not thread safe. In general, an import may not
+ have the side effect of importing a module, and only the main thread
+ should import modules. Imports within or caused by a thread other than
+ the main thread isn't safe.
+
There is the possibility that "dummy thread objects" are created. These are
thread objects corresponding to "alien threads", which are threads of control
started outside the threading module, such as directly from C code. Dummy