[New-bugs-announce] [issue12495] Rewrite InterProcessSignalTests

STINNER Victor report at bugs.python.org
Tue Jul 5 00:33:21 CEST 2011

New submission from STINNER Victor <victor.stinner at haypocalc.com>:

InterProcessSignalTests uses 4 different signal handlers (SIGUSR1, SIGUSR2, SIGALRM, SIGHUP) and uses 2 methods to raise a signal (a subprocess executing "kill -SIG pid" or signal.alarm(1)). It uses signal.pause() and/or time.sleep(1) to wait the signal, or just nothing for SIGUSR2 (configured to be ignored).

The testcase tests too many unrelated things.

signal.alarm(1) is not an interprocess signal: it is a signal send to the process itself.

Why using two different signal handlers? A modifies a_called, B modifies b_called but raise also a Python exception. How is it related to interprocess signal handling?

Why checking that the handler A (SIGHUP) has not been called when the signal handler B (SIGUSR1) is called?

Why is the garbage collector disabled?

I propose to write a new simple testcase: install a signal handler raising a Python exception, send a signal using a child process, ensure that the signal has been received (wait for the exception). Pseudo-code:

s = signal.SIGUSR1
def handler(signum, frame): 1/0
signal.signal(s, handler)
  subprocess.call([sys.executable, '-c', '... kill(%s, %s)' % (os.getpid(), s))
  ... wait the signal ...
except ZeroDivisionError:
  raise Exception("ZeroDivisionError not raised"

The whole test has to be run in a subprocess.

The new test may pass on freebsd 6, it should be checked (see issue #12469).

components: Tests
messages: 139813
nosy: haypo, neologix
priority: normal
severity: normal
status: open
title: Rewrite InterProcessSignalTests
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list