[PATCH 14/16] Import collected modules only once

Chris Lumens clumens at redhat.com
Thu Dec 13 18:55:30 UTC 2012


> diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
> index b1a8dd3..9c3ef8d 100644
> --- a/pyanaconda/ui/common.py
> +++ b/pyanaconda/ui/common.py
> @@ -24,6 +24,7 @@ import os
>  import imp
>  import inspect
>  import copy
> +import sys
>  
>  class PathDict(dict):
>      """Dictionary class supporting + operator"""
> @@ -453,10 +454,13 @@ def collect(module_pattern, path, pred):
>  
>          mod_info = None
>          module = None
> +        
>          try:    
>              imp.acquire_lock()
>              mod_info = imp.find_module(mod_name, [path])
> -            module = imp.load_module(module_pattern % mod_name, *mod_info)
> +            module = sys.modules.get(module_pattern % mod_name)
> +            if not module:
> +                module = imp.load_module(module_pattern % mod_name, *mod_info)
>              imp.release_lock()
>          except ImportError:
>              continue

ACK, but I'm curious under what circumstances you are seeing this, and
if that's bad/dumb behavior that should also be changed.

- Chris


More information about the anaconda-patches mailing list