diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2012-05-18 13:28:02 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2012-05-18 13:28:02 (GMT) |
commit | 77c84f2defb0013e28d262be237142379a1407fe (patch) | |
tree | 16065331749bd8218eb74d80c9f10b54a816c0c5 /Lib/test/test_multiprocessing.py | |
parent | cca802e354f776e79a55b3bc7dded6340b244824 (diff) | |
download | cpython-77c84f2defb0013e28d262be237142379a1407fe.zip cpython-77c84f2defb0013e28d262be237142379a1407fe.tar.gz cpython-77c84f2defb0013e28d262be237142379a1407fe.tar.bz2 |
#12098: Make multiprocessing's child processes inherit sys.flags on Windows
Initial patch by Sergey Mezentsev.
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r-- | Lib/test/test_multiprocessing.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index d10d51b..f02041e 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2814,8 +2814,41 @@ class TestInvalidFamily(unittest.TestCase): with self.assertRaises(ValueError): multiprocessing.connection.Listener('/var/test.pipe') +# +# Issue 12098: check sys.flags of child matches that for parent +# + +class TestFlags(unittest.TestCase): + @classmethod + def run_in_grandchild(cls, conn): + conn.send(tuple(sys.flags)) + + @classmethod + def run_in_child(cls): + import json + r, w = multiprocessing.Pipe(duplex=False) + p = multiprocessing.Process(target=cls.run_in_grandchild, args=(w,)) + p.start() + grandchild_flags = r.recv() + p.join() + r.close() + w.close() + flags = (tuple(sys.flags), grandchild_flags) + print(json.dumps(flags)) + + def test_flags(self): + import json, subprocess + # start child process using unusual flags + prog = ('from test.test_multiprocessing import TestFlags; ' + + 'TestFlags.run_in_child()') + data = subprocess.check_output( + [sys.executable, '-E', '-S', '-O', '-c', prog]) + child_flags, grandchild_flags = json.loads(data.decode('ascii')) + self.assertEqual(child_flags, grandchild_flags) + testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, - TestStdinBadfiledescriptor, TestWait, TestInvalidFamily] + TestStdinBadfiledescriptor, TestWait, TestInvalidFamily, + TestFlags] # # |