[PATCH 1/2] Add function to map functions on items in the main thread

Vratislav Podzimek vpodzime at redhat.com
Wed Nov 13 07:05:36 UTC 2013


On Tue, 2013-11-12 at 11:05 -0500, Chris Lumens wrote:
> > Sometimes we need to map a function on a bunch of items in way that it is called
> > in the main thread. And sometimes we also need to do some transformations on the
> > items before we do the actions that need to take place in the main thread.
> > 
> > This patch adds a versatile function to do those actions in a probably best
> > possible way.
> 
> This is getting really quite fancy!
> 
> > diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
> > index 115ef28..48bc142 100644
> > --- a/pyanaconda/constants.py
> > +++ b/pyanaconda/constants.py
> > @@ -143,3 +143,6 @@ PASSWORD_WEAK_CONFIRM = N_("You have provided a weak password. Press Done again
> >  PASSWORD_WEAK_CONFIRM_WITH_ERROR = N_("You have provided a weak password: %s. Press Done again to use anyway.")
> >  
> >  PASSWORD_STRENGTH_DESC = [N_("Empty"), N_("Weak"), N_("Fair"), N_("Good"), N_("Strong")]
> > +
> > +# the number of seconds we consider a noticeable freeze of the UI
> > +NOTICEABLE_FREEZE = 0.25
> 
> I'd be curious how you arrived at this number.
I've just made it up and then tested if it freezes the main loop for a
noticeable time or not. I mean, it does, but in context of the other
freezes we do (like some of the status/ready properties and things like
that), it looked okay to me. However, that's why I made it a constant
that can be easily tweaked.

> 
> > +# any better idea how to create a unique, distinguishable object that cannot be
> > +# confused with anything else?
> > +TERMINATOR = object()
> 
> Nothing coming to mind, and this seems like a pretty good way to tell.
> 
> > +# any better idea how to ensure thread name uniqueness?u
> > +BATCH_COUNTER = 0
> 
> According to the threading module docs:
> 
> name is the thread name. By default, a unique name is constructed of the
> form “Thread-N” where N is a small decimal number.
> 
> Why don't we add this same functionality to the AnacondaThread object -
> if you don't pass a name, AnacondaThread comes up with the unique name
> for you.
> 
> Alternatively, we could just not care about the "Ana*" namespacing here
> and pass no name, and let threading do the unique bit.  Either would be
> fine with me, I guess.
I'll try to come up with something better in version 2 of the patches.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list