diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2015-01-17 19:02:14 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2015-01-17 19:02:14 (GMT) |
commit | 1285c9b7829a6ae3a1267e7676b1bc2c5ce11f96 (patch) | |
tree | 50e50f3d539ca7b4463bed0926d8ff0cf6927683 /Lib/test/test_concurrent_futures.py | |
parent | 26795baaa812c74087e97f9119ec143451e23daa (diff) | |
download | cpython-1285c9b7829a6ae3a1267e7676b1bc2c5ce11f96.zip cpython-1285c9b7829a6ae3a1267e7676b1bc2c5ce11f96.tar.gz cpython-1285c9b7829a6ae3a1267e7676b1bc2c5ce11f96.tar.bz2 |
Issue #21817: When an exception is raised in a task submitted to a ProcessPoolExecutor, the remote traceback is now displayed in the parent process.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_concurrent_futures.py')
-rw-r--r-- | Lib/test/test_concurrent_futures.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 7f92618..86802c2 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -480,6 +480,32 @@ class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase) ref) self.assertRaises(ValueError, bad_map) + @classmethod + def _test_traceback(cls): + raise RuntimeError(123) # some comment + + def test_traceback(self): + # We want ensure that the traceback from the child process is + # contained in the traceback raised in the main process. + future = self.executor.submit(self._test_traceback) + with self.assertRaises(Exception) as cm: + future.result() + + exc = cm.exception + self.assertIs(type(exc), RuntimeError) + self.assertEqual(exc.args, (123,)) + cause = exc.__cause__ + self.assertIs(type(cause), futures.process._RemoteTraceback) + self.assertIn('raise RuntimeError(123) # some comment', cause.tb) + + with test.support.captured_stderr() as f1: + try: + raise exc + except RuntimeError: + sys.excepthook(*sys.exc_info()) + self.assertIn('raise RuntimeError(123) # some comment', + f1.getvalue()) + class FutureTests(unittest.TestCase): def test_done_callback_with_result(self): |