Skip to content

gh-158497: Keep the worker traceback in ProcessPoolExecutor.map() - #158499

Open
fedonman wants to merge 3 commits into
python:mainfrom
fedonman:fix-executor-map-exceptions
Open

fedonman wants to merge 3 commits into
python:mainfrom
fedonman:fix-executor-map-exceptions

Conversation

@fedonman

@fedonman fedonman commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

ProcessPoolExecutor.map() returned a failed call's exception without the worker traceback. The chunk worker now wraps the exception in _ExceptionWithTraceback, as _process_worker() does. The reference cycle in _MapResultIterator.__next__() that this PR also fixed was fixed on main by gh-74028.

…r.map()`

_process_chunk() returned a failed call's bare exception, so
ProcessPoolExecutor.map() lost the _RemoteTraceback cause that
_process_worker() attaches. Wrap it in _ExceptionWithTraceback.

_MapResultIterator.__next__() kept the exception it raised in a local,
so the exception referenced its own raising frame through its
traceback. Clear the local after raising, as Future.__get_result()
does.
…ceptions

# Conflicts:
#	Lib/concurrent/futures/_base.py
#	Lib/test/test_concurrent_futures/executor.py
@fedonman fedonman changed the title gh-158497: Fix traceback loss and a reference cycle in Executor.map() gh-158497: Keep the worker traceback in ProcessPoolExecutor.map() Nov 3, 2026
@fedonman

fedonman commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@ambv, could you take a look when you have a moment? After gh-74028 this is only the worker traceback part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant