Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,17 @@
processes. This can be used as a performance enhancement to avoid repeated
work in every process.

Only the modules named in *module_names* are imported, together with
whatever those modules import at module level. A module imported inside a
function body is not imported in the forkserver process, and is therefore
imported again in every child process, the first time that function runs
there. For example, preloading :mod:`datetime` does not cover
``_strptime``, which :meth:`~datetime.datetime.strptime` imports on its
first call, so every child pays for that import privately. To share such
modules as well, call the function at the module level of a preloaded
module, so that the import happens in the forkserver process.

For this to work, it must be called before the forkserver process has been

Check warning on line 1255 in Doc/library/multiprocessing.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:class reference target not found: Pool [ref.class]
launched (before creating a :class:`Pool` or starting a :class:`Process`).

The *on_error* parameter controls how :exc:`ImportError` exceptions during
Expand Down
Loading