Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_signal.ItimerTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def sig_alrm
def sig_vtalrm
def sig_prof
def test_itimer_exc
def test_itimer_real
def test_itimer_virtual
def test_itimer_prof

Public Attributes

 hndl_called
 hndl_count
 itimer
 old_alarm

Detailed Description

Definition at line 407 of file test_signal.py.


Member Function Documentation

Definition at line 408 of file test_signal.py.

00408 
00409     def setUp(self):
00410         self.hndl_called = False
00411         self.hndl_count = 0
00412         self.itimer = None
00413         self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm)

Here is the caller graph for this function:

def test.test_signal.ItimerTest.sig_alrm (   self,
  args 
)

Definition at line 420 of file test_signal.py.

00420 
00421     def sig_alrm(self, *args):
00422         self.hndl_called = True
00423         if support.verbose:
00424             print("SIGALRM handler invoked", args)

def test.test_signal.ItimerTest.sig_prof (   self,
  args 
)

Definition at line 443 of file test_signal.py.

00443 
00444     def sig_prof(self, *args):
00445         self.hndl_called = True
00446         signal.setitimer(signal.ITIMER_PROF, 0)
00447 
00448         if support.verbose:
00449             print("SIGPROF handler invoked", args)

Here is the caller graph for this function:

def test.test_signal.ItimerTest.sig_vtalrm (   self,
  args 
)

Definition at line 425 of file test_signal.py.

00425 
00426     def sig_vtalrm(self, *args):
00427         self.hndl_called = True
00428 
00429         if self.hndl_count > 3:
00430             # it shouldn't be here, because it should have been disabled.
00431             raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL "
00432                 "timer.")
00433         elif self.hndl_count == 3:
00434             # disable ITIMER_VIRTUAL, this function shouldn't be called anymore
00435             signal.setitimer(signal.ITIMER_VIRTUAL, 0)
00436             if support.verbose:
00437                 print("last SIGVTALRM handler call")
00438 
00439         self.hndl_count += 1
00440 
00441         if support.verbose:
00442             print("SIGVTALRM handler invoked", args)

Here is the caller graph for this function:

Definition at line 414 of file test_signal.py.

00414 
00415     def tearDown(self):
00416         signal.signal(signal.SIGALRM, self.old_alarm)
00417         if self.itimer is not None: # test_itimer_exc doesn't change this attr
00418             # just ensure that itimer is stopped
00419             signal.setitimer(self.itimer, 0)

Here is the caller graph for this function:

Definition at line 450 of file test_signal.py.

00450 
00451     def test_itimer_exc(self):
00452         # XXX I'm assuming -1 is an invalid itimer, but maybe some platform
00453         # defines it ?
00454         self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0)
00455         # Negative times are treated as zero on some platforms.
00456         if 0:
00457             self.assertRaises(signal.ItimerError,
00458                               signal.setitimer, signal.ITIMER_REAL, -1)

Here is the call graph for this function:

Definition at line 494 of file test_signal.py.

00494 
00495     def test_itimer_prof(self):
00496         self.itimer = signal.ITIMER_PROF
00497         signal.signal(signal.SIGPROF, self.sig_prof)
00498         signal.setitimer(self.itimer, 0.2, 0.2)
00499 
00500         start_time = time.time()
00501         while time.time() - start_time < 60.0:
00502             # do some work
00503             _ = pow(12345, 67890, 10000019)
00504             if signal.getitimer(self.itimer) == (0.0, 0.0):
00505                 break # sig_prof handler stopped this itimer
00506         else: # Issue 8424
00507             self.skipTest("timeout: likely cause: machine too slow or load too "
00508                           "high")
00509 
00510         # profiling itimer should be (0.0, 0.0) now
00511         self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
00512         # and the handler should have been called
00513         self.assertEqual(self.hndl_called, True)

Here is the call graph for this function:

Definition at line 459 of file test_signal.py.

00459 
00460     def test_itimer_real(self):
00461         self.itimer = signal.ITIMER_REAL
00462         signal.setitimer(self.itimer, 1.0)
00463         if support.verbose:
00464             print("\ncall pause()...")
00465         signal.pause()
00466 
00467         self.assertEqual(self.hndl_called, True)

Here is the call graph for this function:

Definition at line 471 of file test_signal.py.

00471 
00472     def test_itimer_virtual(self):
00473         self.itimer = signal.ITIMER_VIRTUAL
00474         signal.signal(signal.SIGVTALRM, self.sig_vtalrm)
00475         signal.setitimer(self.itimer, 0.3, 0.2)
00476 
00477         start_time = time.time()
00478         while time.time() - start_time < 60.0:
00479             # use up some virtual time by doing real work
00480             _ = pow(12345, 67890, 10000019)
00481             if signal.getitimer(self.itimer) == (0.0, 0.0):
00482                 break # sig_vtalrm handler stopped this itimer
00483         else: # Issue 8424
00484             self.skipTest("timeout: likely cause: machine too slow or load too "
00485                           "high")
00486 
00487         # virtual itimer should be (0.0, 0.0) now
00488         self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0))
00489         # and the handler should have been called
00490         self.assertEqual(self.hndl_called, True)

Here is the call graph for this function:


Member Data Documentation

Definition at line 409 of file test_signal.py.

Definition at line 410 of file test_signal.py.

Definition at line 411 of file test_signal.py.

Definition at line 412 of file test_signal.py.


The documentation for this class was generated from the following file: