File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
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 subprocess
17
18
import sys
18
19
from typing import Any
@@ -45,11 +46,21 @@ async def run_driver_async() -> Connection:
45
46
driver_name = compute_driver_name ()
46
47
driver_executable = package_path / "drivers" / driver_name
47
48
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
+
48
59
proc = await asyncio .create_subprocess_exec (
49
60
str (driver_executable ),
50
61
stdin = asyncio .subprocess .PIPE ,
51
62
stdout = asyncio .subprocess .PIPE ,
52
- stderr = sys . stderr ,
63
+ stderr = _get_stderr_fileno () ,
53
64
limit = 32768 ,
54
65
)
55
66
assert proc .stdout
You can’t perform that action at this time.
0 commit comments