Skip to content

Commit 7879081

Browse files
authored
gh-130917: update timer and workload in test_signal (#130918)
The workload to advance the virtual timeout is too lightweight for some platforms. As result the test goes in timeout as it never reaches the end of the timer. By having a heavier workload, the virtual timer advances rapidly and the SIGVTALRM is sent before the timeout.
1 parent b1b4f96 commit 7879081

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_signal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,11 @@ def test_itimer_real(self):
838838
def test_itimer_virtual(self):
839839
self.itimer = signal.ITIMER_VIRTUAL
840840
signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
841-
signal.setitimer(self.itimer, 0.3, 0.2)
841+
signal.setitimer(self.itimer, 0.001, 0.001)
842842

843843
for _ in support.busy_retry(support.LONG_TIMEOUT):
844844
# use up some virtual time by doing real work
845-
_ = pow(12345, 67890, 10000019)
845+
_ = sum(i * i for i in range(10**5))
846846
if signal.getitimer(self.itimer) == (0.0, 0.0):
847847
# sig_vtalrm handler stopped this itimer
848848
break
@@ -859,7 +859,7 @@ def test_itimer_prof(self):
859859

860860
for _ in support.busy_retry(support.LONG_TIMEOUT):
861861
# do some work
862-
_ = pow(12345, 67890, 10000019)
862+
_ = sum(i * i for i in range(10**5))
863863
if signal.getitimer(self.itimer) == (0.0, 0.0):
864864
# sig_prof handler stopped this itimer
865865
break

0 commit comments

Comments
 (0)