File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import asyncio
16+ import io
1617import subprocess
1718import sys
1819from typing import Any
@@ -45,11 +46,21 @@ async def run_driver_async() -> Connection:
4546 driver_name = compute_driver_name ()
4647 driver_executable = package_path / "drivers" / driver_name
4748
49+ # Sourced from: https://github.com/pytest-dev/pytest/blob/49827adcb9256c9c9c06a25729421dcc3c385edc/src/_pytest/faulthandler.py#L73-L80
50+ def _get_stderr_fileno () -> int :
51+ try :
52+ return sys .stderr .fileno ()
53+ except io .UnsupportedOperation :
54+ # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
55+ # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
56+ # This is potentially dangerous, but the best we can do.
57+ return sys .__stderr__ .fileno ()
58+
4859 proc = await asyncio .create_subprocess_exec (
4960 str (driver_executable ),
5061 stdin = asyncio .subprocess .PIPE ,
5162 stdout = asyncio .subprocess .PIPE ,
52- stderr = sys . stderr ,
63+ stderr = _get_stderr_fileno () ,
5364 limit = 32768 ,
5465 )
5566 assert proc .stdout
You can’t perform that action at this time.
0 commit comments