mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-139462: Make the ProcessPoolExecutor BrokenProcessPool exception report which child process terminated (GH-139486)
Report which process terminated as cause of BPE
This commit is contained in:
parent
7906f4d96a
commit
9e7340cd3b
4 changed files with 44 additions and 2 deletions
|
|
@ -474,9 +474,23 @@ def _terminate_broken(self, cause):
|
|||
bpe = BrokenProcessPool("A process in the process pool was "
|
||||
"terminated abruptly while the future was "
|
||||
"running or pending.")
|
||||
cause_str = None
|
||||
if cause is not None:
|
||||
bpe.__cause__ = _RemoteTraceback(
|
||||
f"\n'''\n{''.join(cause)}'''")
|
||||
cause_str = ''.join(cause)
|
||||
else:
|
||||
# No cause known, so report any processes that have
|
||||
# terminated with nonzero exit codes, e.g. from a
|
||||
# segfault. Multiple may terminate simultaneously,
|
||||
# so include all of them in the traceback.
|
||||
errors = []
|
||||
for p in self.processes.values():
|
||||
if p.exitcode is not None and p.exitcode != 0:
|
||||
errors.append(f"Process {p.pid} terminated abruptly "
|
||||
f"with exit code {p.exitcode}")
|
||||
if errors:
|
||||
cause_str = "\n".join(errors)
|
||||
if cause_str:
|
||||
bpe.__cause__ = _RemoteTraceback(f"\n'''\n{cause_str}'''")
|
||||
|
||||
# Mark pending tasks as failed.
|
||||
for work_id, work_item in self.pending_work_items.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue