On Mon, 5 Jun 2000, Luca Minuti wrote:
> I have a problem trying to install a new signal handler.
> I try this program:
>
>
> #!/usr/bin/env python
>
> from signal import *
> from gtk import *
>
> def signal_handler(sig, frame):
> print "Received signal %s" % (sig)
>
> signal(10, signal_handler)
>
> win = GtkWindow()
> win.set_usize(100,100)
> win.show()
> win.connect("destroy", mainquit)
> mainloop()
>
> but if I write:
>
> $ kill -s 10 <pid>
>
> the program answer only after the mainquit.
> If I don't import gtk and I write a simple console application it works. And
> the same program translate in C works.
Python signals are handled asynchronously. Since the interpreter is not
in control while the gtk main loop is running, it won't necessarily get a
chance to run the signal handler.
You can get around this by having a no op function that is called as a
timeout or idle function, so control is passed back to the interpreter
every now and again.
Looking at the python header files, there apears to be a
Py_MakePendingCalls() function that can be used to make sure these
handlers get called. The only question is, how often should it be
called?
>
> Someone can help me?
>
> Thanks.
>
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk