Skip to content

Commit 69d8fe5

Browse files
authored
gh-126548: Add a thread-unsafety warning for importlib.reload() (GH-136704)
1 parent dcd27aa commit 69d8fe5

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)