bpo-36670: regrtest bug fixes (GH-16537) · python/cpython@2ea71a0
@@ -120,27 +120,28 @@ def __init__(self, worker_id, pending, output, ns, timeout):
120120def __repr__(self):
121121info = [f'TestWorkerProcess #{self.worker_id}']
122122if self.is_alive():
123-dt = time.monotonic() - self.start_time
124-info.append("running for %s" % format_duration(dt))
123+info.append("running")
125124else:
126125info.append('stopped')
127126test = self.current_test_name
128127if test:
129128info.append(f'test={test}')
130129popen = self._popen
131-if popen:
132-info.append(f'pid={popen.pid}')
130+if popen is not None:
131+dt = time.monotonic() - self.start_time
132+info.extend((f'pid={self._popen.pid}',
133+f'time={format_duration(dt)}'))
133134return '<%s>' % ' '.join(info)
134135135136def _kill(self):
136-if self._killed:
137-return
138-self._killed = True
139-140137popen = self._popen
141138if popen is None:
142139return
143140141+if self._killed:
142+return
143+self._killed = True
144+144145print(f"Kill {self}", file=sys.stderr, flush=True)
145146try:
146147popen.kill()
@@ -177,9 +178,10 @@ def _run_process(self, test_name):
177178178179self.current_test_name = test_name
179180try:
181+popen = run_test_in_subprocess(test_name, self.ns)
182+180183self._killed = False
181-self._popen = run_test_in_subprocess(test_name, self.ns)
182-popen = self._popen
184+self._popen = popen
183185except:
184186self.current_test_name = None
185187raise