File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
import asyncio
16
+ import io
16
17
import json
17
18
import os
18
19
import sys
19
20
from pathlib import Path
20
- from typing import Dict
21
+ from typing import Dict , Optional
22
+
23
+
24
+ # Sourced from: https://github.com/pytest-dev/pytest/blob/da01ee0a4bb0af780167ecd228ab3ad249511302/src/_pytest/faulthandler.py#L69-L77
25
+ def _get_stderr_fileno () -> Optional [int ]:
26
+ try :
27
+ return sys .stderr .fileno ()
28
+ except (AttributeError , io .UnsupportedOperation ):
29
+ # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
30
+ # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
31
+ # This is potentially dangerous, but the best we can do.
32
+ if not hasattr (sys , "__stderr__" ):
33
+ return None
34
+ return sys .__stderr__ .fileno ()
21
35
22
36
23
37
class Transport :
@@ -41,7 +55,7 @@ async def run(self) -> None:
41
55
"run-driver" ,
42
56
stdin = asyncio .subprocess .PIPE ,
43
57
stdout = asyncio .subprocess .PIPE ,
44
- stderr = sys . stderr ,
58
+ stderr = _get_stderr_fileno () ,
45
59
limit = 32768 ,
46
60
)
47
61
assert proc .stdout
You can’t perform that action at this time.
0 commit comments