lazily import yaml for faster module load times
[invirt/packages/invirt-base.git] / files / usr / share / python-support / sipb-xen-base / invirt / config.py
index 02409a4..cd0a9d4 100644 (file)
@@ -1,4 +1,4 @@
-import json, yaml
+import json
 from invirt.common import *
 from os.path import getmtime
 
 from invirt.common import *
 from os.path import getmtime
 
@@ -36,6 +36,7 @@ def load(src_path = default_src_path,
         # written.
         @with_lock_file('/var/lib/invirt/cache.lock')
         def cfg():
         # written.
         @with_lock_file('/var/lib/invirt/cache.lock')
         def cfg():
+            import yaml
             cfg = with_closing(file(src_path))(lambda f: yaml.load(f, default_loader))
             try: with_closing(file(cache_path, 'w'))(lambda f: f.write(json.write(cfg)))
             except: pass # silent failure
             cfg = with_closing(file(src_path))(lambda f: yaml.load(f, default_loader))
             try: with_closing(file(cache_path, 'w'))(lambda f: f.write(json.write(cfg)))
             except: pass # silent failure