Skip to content

Commit 2817a80

Browse files
authored
fix(windows): hide console window when Pythonw is used (microsoft#729)
1 parent cf985f5 commit 2817a80

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

playwright/_impl/_transport.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io
1717
import json
1818
import os
19+
import subprocess
1920
import sys
2021
from abc import ABC, abstractmethod
2122
from pathlib import Path
@@ -97,6 +98,10 @@ async def wait_until_stopped(self) -> None:
9798

9899
async def run(self) -> None:
99100
self._stopped_future: asyncio.Future = asyncio.Future()
101+
# Hide the command-line window on Windows when using Pythonw.exe
102+
creationflags = 0
103+
if sys.platform == "win32" and sys.stdout is None:
104+
creationflags = subprocess.CREATE_NO_WINDOW
100105

101106
try:
102107
self._proc = proc = await asyncio.create_subprocess_exec(
@@ -106,6 +111,7 @@ async def run(self) -> None:
106111
stdout=asyncio.subprocess.PIPE,
107112
stderr=_get_stderr_fileno(),
108113
limit=32768,
114+
creationflags=creationflags,
109115
)
110116
except Exception as exc:
111117
self.on_error_future.set_exception(exc)

0 commit comments

Comments
 (0)