summaryrefslogtreecommitdiff
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-05-06 11:38:25 +0100
committerRichard Oudkerk <shibturn@gmail.com>2013-05-06 11:38:25 +0100
commit8575783a00a6fc7ef9cb754df90532b178de2fb3 (patch)
tree20f726521104969868978503e8f5da420ce2555c /Lib/test/test_multiprocessing.py
parent53683f6f4bc53a0ffad923a0e056e488dc7dbb6f (diff)
downloadcpython-git-8575783a00a6fc7ef9cb754df90532b178de2fb3.tar.gz
Issue #13813: Embed stringification of remote traceback in local
traceback raised when pool task raises an exception.
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 094bbd6716..3be72c4ad1 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1757,6 +1757,35 @@ class _TestPool(BaseTestCase):
self.assertEqual(r.get(), expected)
self.assertRaises(ValueError, p.map_async, sqr, L)
+ @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.
+ if self.TYPE == 'processes':
+ with self.Pool(1) as p:
+ try:
+ p.apply(self._test_traceback)
+ except Exception as e:
+ exc = e
+ else:
+ raise AssertionError('expected RuntimeError')
+ self.assertIs(type(exc), RuntimeError)
+ self.assertEqual(exc.args, (123,))
+ cause = exc.__cause__
+ self.assertIs(type(cause), multiprocessing.pool.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())
+
def raising():
raise KeyError("key")