Skip to content

Commit 58badb1

Browse files
authored
gh-98552: flush std streams in the multiprocessing forkserver before fork (#141849)
* flush std streams in the multiprocessing forkserver before fork * NEWS
1 parent 08477db commit 58badb1

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
@@ -326,6 +326,7 @@ def sigchld_handler(*_unused):
326326
len(fds)))
327327
child_r, child_w, *fds = fds
328328
s.close()
329+
util._flush_std_streams()
329330
pid = os.fork()
330331
if pid == 0:
331332
# 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)