Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_threadsignals Namespace Reference

Classes

class  ThreadSignals

Functions

def registerSignals
def handle_signals
def send_signals
def test_main

Variables

tuple thread = import_module('_thread')
tuple process_pid = os.getpid()
tuple signalled_all = thread.allocate_lock()
tuple USING_PTHREAD_COND = (sys.platform == 'freebsd6')

Detailed Description

PyUnit testing that threads honor our signal semantics

Function Documentation

def test.test_threadsignals.handle_signals (   sig,
  frame 
)

Definition at line 31 of file test_threadsignals.py.

00031 
00032 def handle_signals(sig,frame):
00033     signal_blackboard[sig]['tripped'] += 1
00034     signal_blackboard[sig]['tripped_by'] = thread.get_ident()
00035 
# a function that will be spawned as a separate thread.
def test.test_threadsignals.registerSignals (   for_usr1,
  for_usr2,
  for_alrm 
)

Definition at line 22 of file test_threadsignals.py.

00022 
00023 def registerSignals(for_usr1, for_usr2, for_alrm):
00024     usr1 = signal.signal(signal.SIGUSR1, for_usr1)
00025     usr2 = signal.signal(signal.SIGUSR2, for_usr2)
00026     alrm = signal.signal(signal.SIGALRM, for_alrm)
00027     return usr1, usr2, alrm
00028 
00029 
00030 # The signal handler. Just note that the signal occurred and
# from who.

Here is the caller graph for this function:

Definition at line 36 of file test_threadsignals.py.

00036 
00037 def send_signals():
00038     os.kill(process_pid, signal.SIGUSR1)
00039     os.kill(process_pid, signal.SIGUSR2)
00040     signalled_all.release()

Definition at line 209 of file test_threadsignals.py.

00209 
00210 def test_main():
00211     global signal_blackboard
00212 
00213     signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 },
00214                           signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 },
00215                           signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } }
00216 
00217     oldsigs = registerSignals(handle_signals, handle_signals, handle_signals)
00218     try:
00219         run_unittest(ThreadSignals)
00220     finally:
00221         registerSignals(*oldsigs)

Here is the call graph for this function:


Variable Documentation

Definition at line 14 of file test_threadsignals.py.

tuple test.test_threadsignals.signalled_all = thread.allocate_lock()

Definition at line 15 of file test_threadsignals.py.

tuple test.test_threadsignals.thread = import_module('_thread')

Definition at line 8 of file test_threadsignals.py.

tuple test.test_threadsignals.USING_PTHREAD_COND = (sys.platform == 'freebsd6')

Definition at line 20 of file test_threadsignals.py.