[Tutor] Using signal handlers

Michael Lange klappnase at freenet.de
Tue Mar 8 22:18:10 CET 2005

Hello tutors,

I experience problems with signal handlers, and the explanatzions in the docs don't
seem to help me much.

The code I try to handle basically comes down to this (it's supposed to run on linux only, btw):

from Tkinter import *
import tkSnack

root = Tk()

initializeSnack() tries to access the sound device, however if this fails it tries forever and doesn't return.
I *thought* a signal handler might be what I need, and in fact it partially works, at least
initializeSnack() is stopped when I add this:

from Tkinter import *
import tkSnack, signal

root = Tk()
signal.signal(signal.SIGALRM, signal.getsignal(signal.SIGALRM))

Now when the audio device is busy, after 5 seconds the app prints "Alarm clock" and exits.
However I would prefer to have a more controlled exit, but as soon as I define a custom
signal handler it's the same as before - it never gets called.

Any help is much appreciated


More information about the Tutor mailing list