Sha256: f71bc9a5500516cacb3e4a3aa8fbac6bee502bed1c51c745bbe74aa01d33df6a

Contents?: true

Size: 1.43 KB

Versions: 30

Compression:

Stored size: 1.43 KB

Contents

# Test the signal module
from test_support import verbose, TestSkipped
import signal
import os
import sys

if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
    raise TestSkipped, "Can't test signal on %s" % sys.platform

if verbose:
    x = '-x'
else:
    x = '+x'
pid = os.getpid()

# Shell script that will send us asynchronous signals
script = """
 (
        set %(x)s
        sleep 2
        kill -5 %(pid)d
        sleep 2
        kill -2 %(pid)d
        sleep 2
        kill -3 %(pid)d
 ) &
""" % vars()

def handlerA(*args):
    if verbose:
        print "handlerA", args

HandlerBCalled = "HandlerBCalled"       # Exception

def handlerB(*args):
    if verbose:
        print "handlerB", args
    raise HandlerBCalled, args

signal.alarm(20)                        # Entire test lasts at most 20 sec.
signal.signal(5, handlerA)
signal.signal(2, handlerB)
signal.signal(3, signal.SIG_IGN)
signal.signal(signal.SIGALRM, signal.default_int_handler)

os.system(script)

print "starting pause() loop..."

try:
    while 1:
        if verbose:
            print "call pause()..."
        try:
            signal.pause()
            if verbose:
                print "pause() returned"
        except HandlerBCalled:
            if verbose:
                print "HandlerBCalled exception caught"
            else:
                pass

except KeyboardInterrupt:
    if verbose:
        print "KeyboardInterrupt (assume the alarm() went off)"

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rubyfox-server-2.19.2.0 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.17.3.2 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.17.3.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.17.3.0 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.3.2 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.3.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.0.4 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.0.3 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.0.2 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.0.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.16.0.0 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.7.3 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.6.2 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.6.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.5.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.4.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.13.3.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.12.5.1 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.12.5.0 lib/rubyfox/server/data/lib/Lib/test/test_signal.py
rubyfox-server-2.12.4.0 lib/rubyfox/server/data/lib/Lib/test/test_signal.py