Skip to content

Commit 60c02ff

Browse files
[3.13] gh-98552: flush std streams in the multiprocessing forkserver before fork (GH-141849) (#141852)
gh-98552: flush std streams in the multiprocessing forkserver before fork (GH-141849) * flush std streams in the multiprocessing forkserver before fork * NEWS (cherry picked from commit 58badb1) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
1 parent 66576c2 commit 60c02ff

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/multiprocessing/forkserver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def sigchld_handler(*_unused):
270270
len(fds)))
271271
child_r, child_w, *fds = fds
272272
s.close()
273+
util._flush_std_streams()
273274
pid = os.fork()
274275
if pid == 0:
275276
# Child
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The :mod:`multiprocessing` forkserver process now flushes stdout and stderr
2+
before it forks to avoid the confusion children inheriting any buffered but
3+
not yet written output data. Normally there is none, but when using
4+
:func:`multiprocessing.set_forkserver_preload` there *could* be.

0 commit comments

Comments
 (0)