Hi all,

I have a console application, using raw_input() (readline) for interface
and SIGALRM for periodic work. Now I added some GUI with PyGTK and all
was fine until I found out that alarm signals stop to arise. The cause
is, to my regret, just 'import gtk'. Here is the code to reproduce:

import signal
import readline # turn on readline

def catcher(signum, _ignored_):
    print "beat!"

if __name__ == "__main__":
    import gtk # <- causes alarm signals not to be delivered

    signal.signal(signal.SIGALRM, catcher)
    signal.setitimer(signal.ITIMER_REAL, 3, 3)

    raw_input() # to expect "beat!" printing until pressing Enter

On the one hand, I need raw_input() to use all goodies that readline
has; on the other hand, using (classic, Unix) signals is the only way to
bypass the blocking of raw_input(). I tried to find the reason of
signals-pygtk conflict for 2 days, but no much results; any help is
appreciate. I am using Ubuntu Karmic, Python 2.6.

As I see from Python sources, blocking behaviour of raw_input() is done
via custom select(), see Modules/readline.c,
readline_until_enter_or_signal(); and when signal SIGALRM is arisen,
select() is interrupted with errno == EINTR which causes my function
catcher() to be invoked (via PyErr_CheckSignals()). But when I 'import
gtk', EINTR stops to arise, how can it happen?

Thanks in advance,
  Ilya Murav'jov
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to