Commit 8f7f3a0
committed
Popen2IO: Fix "Bad file descriptor" error
Fix init_popen_io to leave behind a sane state (0 and 1 file
descriptors open), in order to prevent "Bad file descriptor"
errors. Also fix test_stdouterrin_setnull to restore stdin
state, while relying on capfd to do this for stdout and stderr.
The "Bad file descriptor" error doesn't trigger reliably
because it's triggered by garbage collection of the Popen2IO
instance returned from init_popen_io as shown in this job:
https://github.com/pytest-dev/execnet/actions/runs/7955155978/job/21716386705?pr=243
=================================== FAILURES ===================================
__________________ test_stdouterrin_setnull[main_thread_only] __________________
execmodel = <ExecModel 'main_thread_only'>
capfd = <_pytest.capture.CaptureFixture object at 0x7fba8c333990>
@pytest.mark.skipif("not hasattr(os, 'dup')")
def test_stdouterrin_setnull(execmodel, capfd):
gateway_base.init_popen_io(execmodel)
os.write(1, b"hello")
> os.read(0, 1)
E OSError: [Errno 9] Bad file descriptor
testing/test_basics.py:254: OSError1 parent 6b87f99 commit 8f7f3a0
2 files changed
+30
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
1682 | 1682 | | |
1683 | 1683 | | |
1684 | 1684 | | |
1685 | | - | |
1686 | | - | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
1687 | 1689 | | |
1688 | 1690 | | |
1689 | 1691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
258 | 271 | | |
259 | 272 | | |
260 | 273 | | |
| |||
0 commit comments