Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Nov 18, 2024
1 parent ed9a8e3 commit b2d6a89
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Lib/test/libregrtest/run_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, worker_id: int, runner: "RunWorkers") -> None:
self.timeout = runner.worker_timeout
self.log = runner.log
self.test_name = _NOT_RUNNING
self.start_time = 0.0
self.start_time = time.monotonic()
self._popen: subprocess.Popen[str] | None = None
self._killed = False
self._stopped = False
Expand All @@ -130,7 +130,7 @@ def __repr__(self) -> str:
if test:
info.append(f'test={test}')
popen = self._popen
if popen is not None and self.start_time is not None:
if popen is not None:
dt = time.monotonic() - self.start_time
info.extend((f'pid={popen.pid}',
f'time={format_duration(dt)}'))
Expand Down Expand Up @@ -321,7 +321,6 @@ def read_stdout(self, stdout_file: TextIO) -> str:

def read_json(self, json_file: JsonFile, json_tmpfile: TextIO | None,
stdout: str) -> tuple[TestResult, str]:
test_name = self.test_name
try:
if json_tmpfile is not None:
json_tmpfile.seek(0)
Expand All @@ -336,11 +335,11 @@ def read_json(self, json_file: JsonFile, json_tmpfile: TextIO | None,
# gh-101634: Catch UnicodeDecodeError if stdout cannot be
# decoded from encoding
err_msg = f"Failed to read worker process JSON: {exc}"
raise WorkerError(test_name, err_msg, stdout,
raise WorkerError(self.test_name, err_msg, stdout,
state=State.WORKER_BUG)

if not worker_json:
raise WorkerError(test_name, "empty JSON", stdout,
raise WorkerError(self.test_name, "empty JSON", stdout,
state=State.WORKER_BUG)

try:
Expand All @@ -349,7 +348,7 @@ def read_json(self, json_file: JsonFile, json_tmpfile: TextIO | None,
# gh-101634: Catch UnicodeDecodeError if stdout cannot be
# decoded from encoding
err_msg = f"Failed to parse worker process JSON: {exc}"
raise WorkerError(test_name, err_msg, stdout,
raise WorkerError(self.test_name, err_msg, stdout,
state=State.WORKER_BUG)

return (result, stdout)
Expand Down Expand Up @@ -458,7 +457,7 @@ def get_running(workers: list[WorkerThread]) -> str | None:
running: list[str] = []
for worker in workers:
test_name = worker.test_name
if not test_name or worker.start_time is None:
if not test_name:
continue
dt = time.monotonic() - worker.start_time
if dt >= PROGRESS_MIN_TIME:
Expand Down

0 comments on commit b2d6a89

Please sign in to comment.