File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import asyncio
16+ import io
1617import json
1718import os
1819import sys
1920from 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 ()
2135
2236
2337class Transport :
@@ -41,7 +55,7 @@ async def run(self) -> None:
4155 "run-driver" ,
4256 stdin = asyncio .subprocess .PIPE ,
4357 stdout = asyncio .subprocess .PIPE ,
44- stderr = sys . stderr ,
58+ stderr = _get_stderr_fileno () ,
4559 limit = 32768 ,
4660 )
4761 assert proc .stdout
You can’t perform that action at this time.
0 commit comments