Back to index

python3.2  3.2.2
Public Member Functions
test.test_signal.WakeupSignalTests Class Reference

List of all members.

Public Member Functions

def check_wakeup
def test_wakeup_fd_early
def test_wakeup_fd_during

Detailed Description

Definition at line 235 of file test_signal.py.


Member Function Documentation

def test.test_signal.WakeupSignalTests.check_wakeup (   self,
  test_body 
)

Definition at line 236 of file test_signal.py.

00236 
00237     def check_wakeup(self, test_body):
00238         # use a subprocess to have only one thread and to not change signal
00239         # handling of the parent process
00240         code = """if 1:
00241         import fcntl
00242         import os
00243         import signal
00244 
00245         def handler(signum, frame):
00246             pass
00247 
00248         {}
00249 
00250         signal.signal(signal.SIGALRM, handler)
00251         read, write = os.pipe()
00252         flags = fcntl.fcntl(write, fcntl.F_GETFL, 0)
00253         flags = flags | os.O_NONBLOCK
00254         fcntl.fcntl(write, fcntl.F_SETFL, flags)
00255         signal.set_wakeup_fd(write)
00256 
00257         test()
00258 
00259         os.close(read)
00260         os.close(write)
00261         """.format(test_body)
00262 
00263         assert_python_ok('-c', code)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 288 of file test_signal.py.

00288 
00289     def test_wakeup_fd_during(self):
00290         self.check_wakeup("""def test():
00291             import select
00292             import time
00293 
00294             TIMEOUT_FULL = 10
00295             TIMEOUT_HALF = 5
00296 
00297             signal.alarm(1)
00298             before_time = time.time()
00299             # We attempt to get a signal during the select call
00300             try:
00301                 select.select([read], [], [], TIMEOUT_FULL)
00302             except select.error:
00303                 pass
00304             else:
00305                 raise Exception("select.error not raised")
00306             after_time = time.time()
00307             dt = after_time - before_time
00308             if dt >= TIMEOUT_HALF:
00309                 raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
00310         """)
00311 
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")

Here is the call graph for this function:

Definition at line 264 of file test_signal.py.

00264 
00265     def test_wakeup_fd_early(self):
00266         self.check_wakeup("""def test():
00267             import select
00268             import time
00269 
00270             TIMEOUT_FULL = 10
00271             TIMEOUT_HALF = 5
00272 
00273             signal.alarm(1)
00274             before_time = time.time()
00275             # We attempt to get a signal during the sleep,
00276             # before select is called
00277             time.sleep(TIMEOUT_FULL)
00278             mid_time = time.time()
00279             dt = mid_time - before_time
00280             if dt >= TIMEOUT_HALF:
00281                 raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
00282             select.select([read], [], [], TIMEOUT_FULL)
00283             after_time = time.time()
00284             dt = after_time - mid_time
00285             if dt >= TIMEOUT_HALF:
00286                 raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
00287         """)

Here is the call graph for this function:


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