Merged revisions 75986 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75986 | mark.dickinson | 2009-10-31 10:36:06 +0000 (Sat, 31 Oct 2009) | 2 lines

  Issue #7042:  Use a better mechanism for testing timers in test_signal.
........
This commit is contained in:
Mark Dickinson 2009-10-31 10:38:43 +00:00
parent a25b1312c9
commit a14c2ed15d
1 changed files with 10 additions and 2 deletions

View File

@ -360,11 +360,14 @@ class ItimerTest(unittest.TestCase):
signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
signal.setitimer(self.itimer, 0.3, 0.2)
for i in range(100000000):
start_time = time.time()
while time.time() - start_time < 5.0:
# use up some virtual time by doing real work
_ = pow(12345, 67890, 10000019)
if signal.getitimer(self.itimer) == (0.0, 0.0):
break # sig_vtalrm handler stopped this itimer
else:
self.fail('timeout waiting for sig_vtalrm signal')
# virtual itimer should be (0.0, 0.0) now
self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0))
@ -376,9 +379,14 @@ class ItimerTest(unittest.TestCase):
signal.signal(signal.SIGPROF, self.sig_prof)
signal.setitimer(self.itimer, 0.2, 0.2)
for i in range(100000000):
start_time = time.time()
while time.time() - start_time < 5.0:
# do some work
_ = pow(12345, 67890, 10000019)
if signal.getitimer(self.itimer) == (0.0, 0.0):
break # sig_prof handler stopped this itimer
else:
self.fail('timeout waiting for sig_prof signal')
# profiling itimer should be (0.0, 0.0) now
self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0))