From 78d2b2a67ca292200de2938d5a9d1fce1716356e Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 7 Aug 2020 02:10:04 +0200 Subject: [PATCH] fix: stderr redirect with monkeypatched stderr --- playwright/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/playwright/main.py b/playwright/main.py index 4726ef4bf..049535ec6 100644 --- a/playwright/main.py +++ b/playwright/main.py @@ -13,6 +13,7 @@ # limitations under the License. import asyncio +import io import subprocess import sys from typing import Any @@ -45,11 +46,21 @@ async def run_driver_async() -> Connection: driver_name = compute_driver_name() driver_executable = package_path / "drivers" / driver_name + # Sourced from: https://github.com/pytest-dev/pytest/blob/49827adcb9256c9c9c06a25729421dcc3c385edc/src/_pytest/faulthandler.py#L73-L80 + def _get_stderr_fileno() -> int: + try: + return sys.stderr.fileno() + except io.UnsupportedOperation: + # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file. + # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors + # This is potentially dangerous, but the best we can do. + return sys.__stderr__.fileno() + proc = await asyncio.create_subprocess_exec( str(driver_executable), stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, - stderr=sys.stderr, + stderr=_get_stderr_fileno(), limit=32768, ) assert proc.stdout pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy