Commit c606382
fix: use os.dup() to prevent stdio transport from closing real stdin/stdout
When stdio_server() wraps sys.stdin.buffer / sys.stdout.buffer in
TextIOWrapper, closing or GC'ing the wrapper also closes the
underlying buffer, making sys.stdin/sys.stdout unusable after
the server exits.
Use os.dup() to duplicate the file descriptors before wrapping,
so the wrappers own independent descriptors that can be safely
closed without affecting the original stdio handles.
Fixes #1933
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 62575ed commit c606382
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
0 commit comments