[PATCH 1/2] Add function to map functions on items in the main thread
Chris Lumens
clumens at redhat.com
Tue Nov 12 16:05:48 UTC 2013
> 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.
> +# 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.
- Chris
More information about the anaconda-patches
mailing list