Skip to content

Commit 3bfe2b6

Browse files
miss-islingtonronaldoussorenwillingc
authored
[3.12] gh-105912: document gotcha with using os.fork on macOS (GH-112871) (#113133)
gh-105912: document gotcha with using os.fork on macOS (GH-112871) * 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: Ronald Oussoren <[email protected]> Co-authored-by: Carol Willing <[email protected]>
1 parent 37712ac commit 3bfe2b6

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
@@ -4165,6 +4165,11 @@ written in Python, such as a mail server's external command delivery program.
41654165
If you use TLS sockets in an application calling ``fork()``, see
41664166
the warning in the :mod:`ssl` documentation.
41674167

4168+
.. warning::
4169+
4170+
On macOS the use of this function is unsafe when mixed with using
4171+
higher-level system APIs, and that includes using :mod:`urllib.request`.
4172+
41684173
.. versionchanged:: 3.8
41694174
Calling ``fork()`` in a subinterpreter is no longer supported
41704175
(:exc:`RuntimeError` is raised).
@@ -4204,6 +4209,11 @@ written in Python, such as a mail server's external command delivery program.
42044209

42054210
.. audit-event:: os.forkpty "" os.forkpty
42064211

4212+
.. warning::
4213+
4214+
On macOS the use of this function is unsafe when mixed with using
4215+
higher-level system APIs, and that includes using :mod:`urllib.request`.
4216+
42074217
.. versionchanged:: 3.12
42084218
If Python is able to detect that your process has multiple
42094219
threads, this now raises a :exc:`DeprecationWarning`. See the

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)