Skip to content

Commit 8832239

Browse files
[3.13] gh-126548: Add a thread-unsafety warning for importlib.reload() (GH-136704) (GH-136724)
gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (cherry picked from commit 69d8fe5) Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
1 parent fddb58a commit 8832239

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Doc/library/importlib.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ Functions
206206
:exc:`ModuleNotFoundError` is raised when the module being reloaded lacks
207207
a :class:`~importlib.machinery.ModuleSpec`.
208208

209+
.. warning::
210+
This function is not thread-safe. Calling it from multiple threads can result
211+
in unexpected behavior. It's recommended to use the :class:`threading.Lock`
212+
or other synchronization primitives for thread-safe module reloading.
209213

210214
:mod:`importlib.abc` -- Abstract base classes related to import
211215
---------------------------------------------------------------

0 commit comments

Comments
 (0)