Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _process_chunk(fn, chunk):
try:
result = (fn(*args), None)
except BaseException as exc:
result = (None, exc)
result = (None, _ExceptionWithTraceback(exc, exc.__traceback__))
results.append(result)
return results

Expand Down
12 changes: 11 additions & 1 deletion Lib/test/test_concurrent_futures/test_process_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from test.support import hashlib_helper, threading_helper, warnings_helper
from test.test_importlib.metadata.fixtures import parameterize

from .executor import ExecutorTest, mul
from .executor import ExecutorTest, mul, raiser
from .util import (
ProcessPoolForkMixin, ProcessPoolForkserverMixin, ProcessPoolSpawnMixin,
create_executor_tests, setup_module)
Expand Down Expand Up @@ -141,6 +141,16 @@ def test_traceback(self):
self.assertIn('raise RuntimeError(123) # some comment',
f1.getvalue())

@warnings_helper.ignore_fork_in_thread_deprecation_warnings()
def test_map_traceback(self):
# The traceback from the child process is also kept for map().
i = self.executor.map(raiser, [RuntimeError])
with self.assertRaises(RuntimeError) as cm:
next(i)
cause = cm.exception.__cause__
self.assertIs(type(cause), futures.process._RemoteTraceback)
self.assertIn('raise exception(msg)', cause.tb)

def test_traceback_when_child_process_terminates_abruptly(self):
# gh-139462 enhancement - BrokenProcessPool exceptions
# should describe which process terminated.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix :meth:`Executor.map() <concurrent.futures.Executor.map>` of a
:class:`~concurrent.futures.ProcessPoolExecutor` losing the traceback of an
exception raised in a worker process.
Loading