diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-27 09:52:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-27 09:52:37 (GMT) |
commit | 84a0fbf6b0c2d196ae3995697acf596094b94eb8 (patch) | |
tree | 78d5290cbf1e11903a6abfe6947922a9dbb661f6 /Lib/test | |
parent | 9f6b02ecdedbd033be3e77960aa3abf314fa9db7 (diff) | |
download | cpython-84a0fbf6b0c2d196ae3995697acf596094b94eb8.zip cpython-84a0fbf6b0c2d196ae3995697acf596094b94eb8.tar.gz cpython-84a0fbf6b0c2d196ae3995697acf596094b94eb8.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.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index de894f3..8edb420 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -367,6 +367,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 + + # # # |