refactor: rename DummyProcess to FallbackProcess in Windows stdio (#1015)
This commit is contained in:
parent
674768802a
commit
4d45bb85a8
1 changed files with 6 additions and 6 deletions
|
|
@ -46,7 +46,7 @@ def get_windows_executable_command(command: str) -> str:
|
||||||
return command
|
return command
|
||||||
|
|
||||||
|
|
||||||
class DummyProcess:
|
class FallbackProcess:
|
||||||
"""
|
"""
|
||||||
A fallback process wrapper for Windows to handle async I/O
|
A fallback process wrapper for Windows to handle async I/O
|
||||||
when using subprocess.Popen, which provides sync-only FileIO objects.
|
when using subprocess.Popen, which provides sync-only FileIO objects.
|
||||||
|
|
@ -115,7 +115,7 @@ async def create_windows_process(
|
||||||
env: dict[str, str] | None = None,
|
env: dict[str, str] | None = None,
|
||||||
errlog: TextIO | None = sys.stderr,
|
errlog: TextIO | None = sys.stderr,
|
||||||
cwd: Path | str | None = None,
|
cwd: Path | str | None = None,
|
||||||
) -> DummyProcess:
|
) -> FallbackProcess:
|
||||||
"""
|
"""
|
||||||
Creates a subprocess in a Windows-compatible way.
|
Creates a subprocess in a Windows-compatible way.
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ async def create_windows_process(
|
||||||
cwd (Path | str | None): Working directory for the subprocess
|
cwd (Path | str | None): Working directory for the subprocess
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DummyProcess: Async-compatible subprocess with stdin and stdout streams
|
FallbackProcess: Async-compatible subprocess with stdin and stdout streams
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Try launching with creationflags to avoid opening a new console window
|
# Try launching with creationflags to avoid opening a new console window
|
||||||
|
|
@ -145,7 +145,7 @@ async def create_windows_process(
|
||||||
bufsize=0, # Unbuffered output
|
bufsize=0, # Unbuffered output
|
||||||
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0),
|
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0),
|
||||||
)
|
)
|
||||||
return DummyProcess(popen_obj)
|
return FallbackProcess(popen_obj)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# If creationflags failed, fallback without them
|
# If creationflags failed, fallback without them
|
||||||
|
|
@ -158,10 +158,10 @@ async def create_windows_process(
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
bufsize=0,
|
bufsize=0,
|
||||||
)
|
)
|
||||||
return DummyProcess(popen_obj)
|
return FallbackProcess(popen_obj)
|
||||||
|
|
||||||
|
|
||||||
async def terminate_windows_process(process: Process | DummyProcess):
|
async def terminate_windows_process(process: Process | FallbackProcess):
|
||||||
"""
|
"""
|
||||||
Terminate a Windows process.
|
Terminate a Windows process.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue