mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #6056: Make multiprocessing use setblocking(True) on the sockets it uses.
Original patch by J Derek Wilson.
This commit is contained in:
parent
a58d668fd9
commit
4887b1c0e7
4 changed files with 44 additions and 1 deletions
|
@ -2395,9 +2395,43 @@ class TestInvalidFamily(unittest.TestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
multiprocessing.connection.Listener('/var/test.pipe')
|
||||
|
||||
#
|
||||
# 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, TestInvalidFamily]
|
||||
TestStdinBadfiledescriptor, TestInvalidFamily,
|
||||
TestTimeouts]
|
||||
|
||||
#
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue