summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-16 17:03:06 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-16 17:03:06 (GMT)
commit9c182a1e25409a241cf1f7e8d0141199dd4344c9 (patch)
treeae20366942a90a48d12207de703d676187bcfec7 /Lib
parent6d3c09f284974c2c97918d0bb63af25d0fba27aa (diff)
downloadcpython-9c182a1e25409a241cf1f7e8d0141199dd4344c9.zip
cpython-9c182a1e25409a241cf1f7e8d0141199dd4344c9.tar.gz
cpython-9c182a1e25409a241cf1f7e8d0141199dd4344c9.tar.bz2
Issue #23680: Reduce risk of race condition in check_interrupted_write() of
test_io. Allocate the large data before scheduling an alarm in 1 second. On very slow computer, the alarm rings sometimes during the memory allocation.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_io.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index abbd661..e5c6073 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3431,6 +3431,7 @@ class SignalsTest(unittest.TestCase):
t.daemon = True
r, w = os.pipe()
fdopen_kwargs["closefd"] = False
+ large_data = item * (support.PIPE_MAX_SIZE // len(item) + 1)
try:
wio = self.io.open(w, **fdopen_kwargs)
t.start()
@@ -3442,8 +3443,7 @@ class SignalsTest(unittest.TestCase):
# handlers, which in this case will invoke alarm_interrupt().
signal.alarm(1)
try:
- self.assertRaises(ZeroDivisionError,
- wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1))
+ self.assertRaises(ZeroDivisionError, wio.write, large_data)
finally:
signal.alarm(0)
t.join()