You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Fix" fork() so it "works" on Python 3.13, and "works" better on older Python versions (#1047)
Behavior change: threads created by eventlet.green.threading.Thread and threading.Thead will be visible across both modules if monkey patching was used. Previously each module would only list threads created in that module.
Bug fix: after fork(), greenlet threads are correctly listed in threading.enumerate() if monkey patching was used. You should not use fork()-without-execve().
Co-authored-by: Itamar Turner-Trauring <[email protected]>
Most subprocesses replace the child process with a new executable, wiping out all memory from the parent process.
6
+
A ``fork()ed`` subprocess can choose not to do this, and preserve data from the parent process.
7
+
(Technically this is ``fork()`` without ``execve()``.)
8
+
9
+
This is a terrible idea, as it can cause deadlocks, memory corruption, and crashes.
10
+
11
+
For backwards compatibility, Eventlet *tries* to work in this case, but this is very much not guaranteed and your program may suffer from deadlocks, memory corruption, and crashes.
12
+
This is even more so when using the ``asyncio`` hub, as that requires even more questionable interventions to "work".
13
+
14
+
This is not a problem with Eventlet.
15
+
It's a fundamental problem with ``fork()`` applicable to pretty much every Python program.
16
+
17
+
Below are some common reasons you might be using ``fork()`` without knowing it, and what you can do about it.
18
+
19
+
``multiprocessing``
20
+
------------------
21
+
22
+
On Linux, on Python 3.13 earlier, the standard library ``multiprocessing`` library uses ``fork()`` by default.
23
+
To fix this, switch to the ``"spawn"`` method (the default in Python 3.14 and later) as `documented here <https://docs.python.org/3.13/library/multiprocessing.html#contexts-and-start-methods>`.
24
+
25
+
26
+
``oslo.service``
27
+
----------------
28
+
29
+
There are alternative ways of running services that do not use ``fork()``.
0 commit comments