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.
This commit is contained in:
parent
6d3c09f284
commit
9c182a1e25
|
@ -3431,6 +3431,7 @@ class SignalsTest(unittest.TestCase):
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
r, w = os.pipe()
|
r, w = os.pipe()
|
||||||
fdopen_kwargs["closefd"] = False
|
fdopen_kwargs["closefd"] = False
|
||||||
|
large_data = item * (support.PIPE_MAX_SIZE // len(item) + 1)
|
||||||
try:
|
try:
|
||||||
wio = self.io.open(w, **fdopen_kwargs)
|
wio = self.io.open(w, **fdopen_kwargs)
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -3442,8 +3443,7 @@ class SignalsTest(unittest.TestCase):
|
||||||
# handlers, which in this case will invoke alarm_interrupt().
|
# handlers, which in this case will invoke alarm_interrupt().
|
||||||
signal.alarm(1)
|
signal.alarm(1)
|
||||||
try:
|
try:
|
||||||
self.assertRaises(ZeroDivisionError,
|
self.assertRaises(ZeroDivisionError, wio.write, large_data)
|
||||||
wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1))
|
|
||||||
finally:
|
finally:
|
||||||
signal.alarm(0)
|
signal.alarm(0)
|
||||||
t.join()
|
t.join()
|
||||||
|
|
Loading…
Reference in New Issue