summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-27 09:53:35 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-27 09:53:35 (GMT)
commit2d843d25204af3a791f31b1b941675da49be82ed (patch)
tree8726d48e8a575217c26ea4a0a5ceaf19d9bd70b5 /Lib/test
parente10ae8871a057d6afb5a4c5650e0ed029f13721d (diff)
parent84a0fbf6b0c2d196ae3995697acf596094b94eb8 (diff)
downloadcpython-2d843d25204af3a791f31b1b941675da49be82ed.zip
cpython-2d843d25204af3a791f31b1b941675da49be82ed.tar.gz
cpython-2d843d25204af3a791f31b1b941675da49be82ed.tar.bz2
Issue #13812: When a multiprocessing Process child raises an exception, flush stderr after printing the exception traceback.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_multiprocessing.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 93cc11d..e5beb97 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -417,6 +417,29 @@ class _TestSubclassingProcess(BaseTestCase):
uppercaser.stop()
uppercaser.join()
+ def test_stderr_flush(self):
+ # sys.stderr is flushed at process shutdown (issue #13812)
+ if self.TYPE == "threads":
+ return
+
+ testfn = test.support.TESTFN
+ self.addCleanup(test.support.unlink, testfn)
+ proc = self.Process(target=self._test_stderr_flush, args=(testfn,))
+ proc.start()
+ proc.join()
+ with open(testfn, 'r') as f:
+ err = f.read()
+ # The whole traceback was printed
+ self.assertIn("ZeroDivisionError", err)
+ self.assertIn("test_multiprocessing.py", err)
+ self.assertIn("1/0 # MARKER", err)
+
+ @classmethod
+ def _test_stderr_flush(cls, testfn):
+ sys.stderr = open(testfn, 'w')
+ 1/0 # MARKER
+
+
#
#
#