On Fri, 28 Feb 2003, Christian Reis wrote:

> On Fri, Feb 28, 2003 at 08:56:04AM -0600, Jon Nelson wrote:
> > To make progress bars work, I use the following code:
> >
> >       while gtk.events_pending():
> >         gtk.mainiteration(0)
> >
> > And here is where I get into trouble.
> >
> > Assume the FIFO is still readable (perhaps I haven't read all of the
> > data, or perhaps new data has arrived).
> >
> > It appears that gtk.mainiteration will call read_from_fifo *again*,
> > which calls handle_fifo, which may result in calling mainiteration,
> > which may result in read_from_fifo being called, which ....
>
> Why not just use a global variable to lock this? Something like
>
>     self.block_read = 1
>
> and then set this just before your mainiteration loop. Then check for it
> inside read_from_fifo and only perform the actual read if you aren't
> blocked.

I tried that very approach, and it didn't work for me.  I didn't spend a
great deal of time trying to figure out why. I'll look into it.

> > I've tried the following approaches:
> >
> > 1. don't call handle_fifo directly, use an idle function (same problem)
> > 2. don't call handle_fifo directly, use a timeout function (same
> > problem)
> > 3. [incorrectly] use gtk.threads_{enter,leave} <- many scary locks.
> > Wrong approach.
> > 4. in handle_fifo, call gtk.input_remove(self.fifo_tag) and set
> > self.fifo_tag appropriately, and later re-enable it when my work is
> > done.  <- why doesn't this work?
>
> I think this isn't really related to threads at all, but IMBW.

Right. Thus the [incorrectly].  At that time I was grasping at straws.

..

> > 1. is there a better way to do this?
> > 2. why doesn't #4 above work?
>
> Possibly because of the order things are being processed inside GTK. I
> would have to have a look at the input handling code but that comes to
> mind as a definite possibility.

..

--
"Never try to write to ROM - it wastes your time and annoys the ROM."

Jon Nelson <[EMAIL PROTECTED]>
C and Python Code Gardener
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to