summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2012-07-27 13:19:00 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2012-07-27 13:19:00 (GMT)
commitb15e622bb884085a01a0095fb611005680ed68f7 (patch)
treeeef859348e8033b7d63831e199a327a4676b412d /Lib/test/test_multiprocessing.py
parent46874ad367c2f3fdd47b2c8cb4b405bbcb2ed14a (diff)
downloadcpython-b15e622bb884085a01a0095fb611005680ed68f7.zip
cpython-b15e622bb884085a01a0095fb611005680ed68f7.tar.gz
cpython-b15e622bb884085a01a0095fb611005680ed68f7.tar.bz2
Issue #6056: Make multiprocessing use setblocking(True) on the sockets it uses.
Original patch by J Derek Wilson.
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index f6f4f73..afb0bee 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -3312,9 +3312,43 @@ class TestFlags(unittest.TestCase):
child_flags, grandchild_flags = json.loads(data.decode('ascii'))
self.assertEqual(child_flags, grandchild_flags)
+#
+# Test interaction with socket timeouts - see Issue #6056
+#
+
+class TestTimeouts(unittest.TestCase):
+ @classmethod
+ def _test_timeout(cls, child, address):
+ time.sleep(1)
+ child.send(123)
+ child.close()
+ conn = multiprocessing.connection.Client(address)
+ conn.send(456)
+ conn.close()
+
+ def test_timeout(self):
+ old_timeout = socket.getdefaulttimeout()
+ try:
+ socket.setdefaulttimeout(0.1)
+ parent, child = multiprocessing.Pipe(duplex=True)
+ l = multiprocessing.connection.Listener(family='AF_INET')
+ p = multiprocessing.Process(target=self._test_timeout,
+ args=(child, l.address))
+ p.start()
+ child.close()
+ self.assertEqual(parent.recv(), 123)
+ parent.close()
+ conn = l.accept()
+ self.assertEqual(conn.recv(), 456)
+ conn.close()
+ l.close()
+ p.join(10)
+ finally:
+ socket.setdefaulttimeout(old_timeout)
+
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
TestStdinBadfiledescriptor, TestWait, TestInvalidFamily,
- TestFlags]
+ TestFlags, TestTimeouts]
#
#