Skip to content

bpo-36670, regrtest: Fix repr(TestWorkerProcess) #16537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Lib/test/libregrtest/runtest_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,28 @@ def __init__(self, worker_id, pending, output, ns, timeout):
def __repr__(self):
info = [f'TestWorkerProcess #{self.worker_id}']
if self.is_alive():
dt = time.monotonic() - self.start_time
info.append("running for %s" % format_duration(dt))
info.append("running")
else:
info.append('stopped')
test = self.current_test_name
if test:
info.append(f'test={test}')
popen = self._popen
if popen:
info.append(f'pid={popen.pid}')
if popen is not None:
dt = time.monotonic() - self.start_time
info.extend((f'pid={self._popen.pid}',
f'time={format_duration(dt)}'))
return '<%s>' % ' '.join(info)

def _kill(self):
if self._killed:
return
self._killed = True

popen = self._popen
if popen is None:
return

if self._killed:
return
self._killed = True

print(f"Kill {self}", file=sys.stderr, flush=True)
try:
popen.kill()
Expand Down Expand Up @@ -177,9 +178,10 @@ def _run_process(self, test_name):

self.current_test_name = test_name
try:
popen = run_test_in_subprocess(test_name, self.ns)

self._killed = False
self._popen = run_test_in_subprocess(test_name, self.ns)
popen = self._popen
self._popen = popen
except:
self.current_test_name = None
raise
Expand Down