Skip to content

Commit d9fa578

Browse files
committed
Add flush=True before os._exit and add NEWS entry
os._exit() does not flush Python IO buffers, so the print(os.getpid()) output was lost when stdout is piped. Add flush=True to ensure the child PID reaches the parent. Also add the required NEWS entry. <claude>
1 parent d9b8d13 commit d9fa578

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def baz_fork():
116116
def foo():
117117
pid = os.fork()
118118
if pid == 0:
119-
print(os.getpid())
119+
print(os.getpid(), flush=True)
120120
baz_fork()
121121
os._exit(0)
122122
else:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix flaky :func:`test_trampoline_works_with_forks` by using ``os._exit(0)``
2+
in the fork child to avoid fragile Python finalization, and by flushing
3+
stdout before exit. Also fix the parent's wait status handling to use
4+
``os.WEXITSTATUS()``.

0 commit comments

Comments
 (0)