summaryrefslogtreecommitdiffstats
path: root/Doc/library/os.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r--Doc/library/os.rst36
1 files changed, 32 insertions, 4 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index c67b966..74897a7 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -4157,15 +4157,38 @@ written in Python, such as a mail server's external command delivery program.
.. audit-event:: os.fork "" os.fork
+ .. warning::
+
+ If you use TLS sockets in an application calling ``fork()``, see
+ the warning in the :mod:`ssl` documentation.
+
.. versionchanged:: 3.8
Calling ``fork()`` in a subinterpreter is no longer supported
(:exc:`RuntimeError` is raised).
- .. warning::
-
- See :mod:`ssl` for applications that use the SSL module with fork().
+ .. versionchanged:: 3.12
+ If Python is able to detect that your process has multiple
+ threads, :func:`os.fork` now raises a :exc:`DeprecationWarning`.
+
+ We chose to surface this as a warning, when detectable, to better
+ inform developers of a design problem that the POSIX platform
+ specifically notes as not supported. Even in code that
+ *appears* to work, it has never been safe to mix threading with
+ :func:`os.fork` on POSIX platforms. The CPython runtime itself has
+ always made API calls that are not safe for use in the child
+ process when threads existed in the parent (such as ``malloc`` and
+ ``free``).
+
+ Users of macOS or users of libc or malloc implementations other
+ than those typically found in glibc to date are among those
+ already more likely to experience deadlocks running such code.
+
+ See `this discussion on fork being incompatible with threads
+ <https://discuss.python.org/t/33555>`_
+ for technical details of why we're surfacing this longstanding
+ platform compatibility problem to developers.
- .. availability:: Unix, not Emscripten, not WASI.
+ .. availability:: POSIX, not Emscripten, not WASI.
.. function:: forkpty()
@@ -4178,6 +4201,11 @@ written in Python, such as a mail server's external command delivery program.
.. audit-event:: os.forkpty "" os.forkpty
+ .. versionchanged:: 3.12
+ If Python is able to detect that your process has multiple
+ threads, this now raises a :exc:`DeprecationWarning`. See the
+ longer explanation on :func:`os.fork`.
+
.. versionchanged:: 3.8
Calling ``forkpty()`` in a subinterpreter is no longer supported
(:exc:`RuntimeError` is raised).