summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-10-22 09:40:31 (GMT)
committerGitHub <noreply@github.com>2017-10-22 09:40:31 (GMT)
commitdaeefd2e049b74340307481112a39f77de0f4769 (patch)
tree7b55a2b183b67fef2f41257d2a87b3f2e87ee02e /Lib/test/_test_multiprocessing.py
parent73c4708630f99b94c35476529748629fff1fc63e (diff)
downloadcpython-daeefd2e049b74340307481112a39f77de0f4769.zip
cpython-daeefd2e049b74340307481112a39f77de0f4769.tar.gz
cpython-daeefd2e049b74340307481112a39f77de0f4769.tar.bz2
bpo-28326: Fix multiprocessing.Process when stdout and/or stderr is closed or None. (#4073)
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 8e004e2..69c0bd8 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -582,6 +582,27 @@ class _TestProcess(BaseTestCase):
proc.join()
self.assertTrue(evt.is_set())
+ @classmethod
+ def _test_error_on_stdio_flush(self, evt):
+ evt.set()
+
+ def test_error_on_stdio_flush(self):
+ streams = [io.StringIO(), None]
+ streams[0].close()
+ for stream_name in ('stdout', 'stderr'):
+ for stream in streams:
+ old_stream = getattr(sys, stream_name)
+ setattr(sys, stream_name, stream)
+ try:
+ evt = self.Event()
+ proc = self.Process(target=self._test_error_on_stdio_flush,
+ args=(evt,))
+ proc.start()
+ proc.join()
+ self.assertTrue(evt.is_set())
+ finally:
+ setattr(sys, stream_name, old_stream)
+
#
#