As you may have noticed, I'm writing a program that tries to track
several of its children.  It gets notified of a child's death by
SIGCHLD.  The problem is that Python signal processing is synchronous
-- while in the C signal handler, Python simply queues the routine to
be run at a later time.  In some cases, this doesn't matter because a
callback gets run because of the file descriptors that got closed.
But in other cases, such as exec-ing "sleep 1", the subprocess' death
goes unnoticed until the first time a Python callback is invoked.

I think this is fixable because of the fact that a signal will
interrupt glib's poll.  I'd love to be able to specify code to be run
between iterations.  The code would be a no-op, but it would be enough
to let Python flush its queue.  For instance:

    # Setup a dummy function that gives Python a chance to flush its
    # signal queues.
    iteration_add (lambda *args: TRUE)

Since I haven't found a way to do this, I tried a different approach;
writing a mainloop myself, using the blocking version of
gtk_main_iteration().  It looks like this:

class MainLoop:
    def __init__ (self):
        self.running = 1
        quit_add (1, self.__reset)
        while self.running:
            mainiteration (block = TRUE)

    def __reset (self):
        print "called"
        self.running = 0

This code works nice as it is -- the death of "sleep 1" is now
noticed.  The problem is that the above loop never exits because
calling mainquit() doesn't invoke MainLoop.__reset__!  It was quite a
shock to find out that mainquit() doesn't bother to call the stuff
registered with quit_add(), even though mainiteration() is in
progress.

I wonder if that's a bug or a feature...
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to