[newui] [PATCH] Check that Gtk.main is not already running before starting another one

Vratislav Podzimek vpodzime at redhat.com
Mon Aug 6 15:33:34 UTC 2012


On Fri, 2012-08-03 at 14:44 -0400, Chris Lumens wrote:
> > diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
> > index 70deed5..00c1696 100644
> > --- a/pyanaconda/exception.py
> > +++ b/pyanaconda/exception.py
> > @@ -131,6 +131,9 @@ class AnacondaExceptionHandler(ExceptionHandler):
> >          except SystemError:
> >              pass
> >  
> > +    def runQuit(self, *args):
> > +        os.system("systemctl --no-wall reboot")
> > +
> >  def initExceptionHandling(anaconda):
> >      fileList = [ "/tmp/anaconda.log",
> >                   "/tmp/program.log", "/tmp/storage.log", "/tmp/ifcfg.log",
> 
> I think runQuit need to use the same kind of code we do elsewhere to
> make sure anaconda's exitHandler function gets run.  I'd like to make
> sure every way out of anaconda passes through that function.
> 
> > @@ -87,6 +88,13 @@ class GraphicalUserInterface(UserInterface):
> >      def run(self):
> >          from gi.repository import Gtk
> >  
> > +        if Gtk.main_level() > 0:
> > +            # Gtk main loop running. That means python-meh caught exception
> > +            # and runs its main loop. Do not crash Gtk by running another one
> > +            # from a different thread and just wait for the reboot.
> > +            while True:
> > +                time.sleep(10000)
> > +
> >          from pyanaconda.product import isFinal, productName, productVersion
> >  
> >          # If we set these values on the very first window shown, they will get
> 
> Seems a bit ungraceful, but at least there's a helpful comment.  The
> best alternative I can suggest is joining on a thread but you'd have to
> figure out which one to join on first.
I believe we could use busy-wait here. Periodically (e.g. every 2
seconds) test the Gtk.main_level() and when it falls to 0, run
sys.exit(0). This way the exitHandler would be called at exit and we
would not have to care about what thread crashed.
Or we could write out the thread's name to a file in handleException,
read it here and join the thread. Then run sys.exit(0). But this would
be more complicated and I don't see any problem in a busy-wait in this
case (exception appeared before UI started).

--
Vratislav Podzimek




More information about the anaconda-patches mailing list