Skip to content

Commit

Permalink
Enhance error handling and Windows compatibility in failure handler a…
Browse files Browse the repository at this point in the history
…nd process wrapper
  • Loading branch information
polischuks committed Feb 15, 2025
1 parent 6984a1d commit f38f7db
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hstest/testing/process_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import subprocess
import sys
from threading import Lock, Thread
Expand Down Expand Up @@ -67,6 +68,14 @@ def start(self):

args = ["cmd", "/c", *args]

# Set environment variables for proper encoding on Windows
env = os.environ.copy()
if is_windows():
env.update({
'PYTHONIOENCODING': 'utf-8',
'PYTHONLEGACYWINDOWSSTDIO': '0' # Disable legacy stdio behavior on Windows
})

self.process = subprocess.Popen(
args,
bufsize=0,
Expand All @@ -75,6 +84,8 @@ def start(self):
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
encoding="utf-8" if not self._use_byte_stream else None,
errors='replace', # Handle encoding errors gracefully
env=env
)
except Exception as e:
from hstest import StageTest
Expand Down

0 comments on commit f38f7db

Please sign in to comment.