Skip to content

Commit 11401e2

Browse files
[3.11] gh-105912: document gotcha with using os.fork on macOS (GH-112871) (#113135)
* gh-105912: document gotcha with using os.fork on macOS Using ``fork(2)`` on macOS when also using higher-level system APIs in the parent proces can crash on macOS because those system APIs are not written to handle this usage pattern. There's nothing we can do about this other than documenting the problem. (cherry picked from commit 22511f7) Co-authored-by: Carol Willing <[email protected]>
1 parent 2be7a72 commit 11401e2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

Doc/library/os.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,11 @@ written in Python, such as a mail server's external command delivery program.
39283928

39293929
.. audit-event:: os.fork "" os.fork
39303930

3931+
.. warning::
3932+
3933+
On macOS the use of this function is unsafe when mixed with using
3934+
higher-level system APIs, and that includes using :mod:`urllib.request`.
3935+
39313936
.. versionchanged:: 3.8
39323937
Calling ``fork()`` in a subinterpreter is no longer supported
39333938
(:exc:`RuntimeError` is raised).
@@ -3949,6 +3954,11 @@ written in Python, such as a mail server's external command delivery program.
39493954

39503955
.. audit-event:: os.forkpty "" os.forkpty
39513956

3957+
.. warning::
3958+
3959+
On macOS the use of this function is unsafe when mixed with using
3960+
higher-level system APIs, and that includes using :mod:`urllib.request`.
3961+
39523962
.. versionchanged:: 3.8
39533963
Calling ``forkpty()`` in a subinterpreter is no longer supported
39543964
(:exc:`RuntimeError` is raised).

Doc/library/pty.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ The :mod:`pty` module defines the following functions:
3333
file descriptor connected to the child's controlling terminal (and also to the
3434
child's standard input and output).
3535

36+
.. warning:: On macOS the use of this function is unsafe when mixed with using
37+
higher-level system APIs, and that includes using :mod:`urllib.request`.
38+
3639

3740
.. function:: openpty()
3841

Doc/library/urllib.request.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ authentication, redirections, cookies and more.
2121
The `Requests package <https://requests.readthedocs.io/en/master/>`_
2222
is recommended for a higher-level HTTP client interface.
2323

24+
.. warning::
25+
26+
On macOS it is unsafe to use this module in programs using
27+
:func:`os.fork` because the :func:`getproxies` implementation for
28+
macOS uses a higher-level system API. Set the environment variable
29+
``no_proxy`` to ``*`` to avoid this problem
30+
(e.g. ``os.environ["no_proxy"] = "*"``).
31+
2432
.. include:: ../includes/wasm-notavail.rst
2533

2634
The :mod:`urllib.request` module defines the following functions:

0 commit comments

Comments
 (0)