]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704)
authorBartosz Sławecki <bartosz@ilikepython.com>
Wed, 16 Jul 2025 16:34:14 +0000 (18:34 +0200)
committerGitHub <noreply@github.com>
Wed, 16 Jul 2025 16:34:14 +0000 (12:34 -0400)
Doc/library/importlib.rst

index ea5a77028683b365f438357e10d987340302e609..4f374be778d6b32b98ad761847d7a17446092d63 100644 (file)
@@ -206,6 +206,10 @@ Functions
        :exc:`ModuleNotFoundError` is raised when the module being reloaded lacks
        a :class:`~importlib.machinery.ModuleSpec`.
 
+   .. warning::
+      This function is not thread-safe. Calling it from multiple threads can result
+      in unexpected behavior. It's recommended to use the :class:`threading.Lock`
+      or other synchronization primitives for thread-safe module reloading.
 
 :mod:`importlib.abc` -- Abstract base classes related to import
 ---------------------------------------------------------------