https://github.com/python/cpython/commit/60c02ff714fa47d45e032c497413b8e3d7ad9767 commit: 60c02ff714fa47d45e032c497413b8e3d7ad9767 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: gpshead <[email protected]> date: 2025-11-22T12:23:30-08:00 summary:
[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 58badb1711e12b6e8b5240ab96cdd01b95012de7) Co-authored-by: Gregory P. Smith <[email protected]> files: A Misc/NEWS.d/next/Library/2025-11-22-18-00-38.gh-issue-98552.d5KNy-.rst M Lib/multiprocessing/forkserver.py diff --git a/Lib/multiprocessing/forkserver.py b/Lib/multiprocessing/forkserver.py index e243442e7a15bd..f0e94178a4af65 100644 --- a/Lib/multiprocessing/forkserver.py +++ b/Lib/multiprocessing/forkserver.py @@ -270,6 +270,7 @@ def sigchld_handler(*_unused): len(fds))) child_r, child_w, *fds = fds s.close() + util._flush_std_streams() pid = os.fork() if pid == 0: # Child diff --git a/Misc/NEWS.d/next/Library/2025-11-22-18-00-38.gh-issue-98552.d5KNy-.rst b/Misc/NEWS.d/next/Library/2025-11-22-18-00-38.gh-issue-98552.d5KNy-.rst new file mode 100644 index 00000000000000..37a71ac1fff3f3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-11-22-18-00-38.gh-issue-98552.d5KNy-.rst @@ -0,0 +1,4 @@ +The :mod:`multiprocessing` forkserver process now flushes stdout and stderr +before it forks to avoid the confusion children inheriting any buffered but +not yet written output data. Normally there is none, but when using +:func:`multiprocessing.set_forkserver_preload` there *could* be. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
