Index: trunk/packages/invirt-base/python/invirt/config.py
===================================================================
--- trunk/packages/invirt-base/python/invirt/config.py	(revision 1420)
+++ trunk/packages/invirt-base/python/invirt/config.py	(revision 1421)
@@ -6,8 +6,19 @@
 from os.path import getmtime
 from contextlib import closing
+import yaml
+
+try:    loader = yaml.CSafeLoader
+except: loader = yaml.SafeLoader
 
 src_path   = '/etc/invirt/master.yaml'
 cache_path = '/var/lib/invirt/cache.json'
 lock_path  = '/var/lib/invirt/cache.lock'
+
+def load_master():
+    with closing(file(src_path)) as f:
+        return yaml.load(f, loader)
+
+def get_src_mtime():
+    return getmtime(src_path)
 
 def load(force_refresh = False):
@@ -26,5 +37,5 @@
         do_refresh = True
     else:
-        src_mtime = getmtime(src_path)
+        src_mtime = get_src_mtime()
         try:            cache_mtime = getmtime(cache_path)
         except OSError: do_refresh  = True
@@ -67,11 +78,7 @@
         # transactionally isolated from the above cache read.  If we fail to
         # acquire the lock, just try to load the master configuration.
-        import yaml
-        try:    loader = yaml.CSafeLoader
-        except: loader = yaml.SafeLoader
         try:
             with lock_file(lock_path):
-                with closing(file(src_path)) as f:
-                    ns.cfg = yaml.load(f, loader)
+                ns.cfg = load_master()
                 try: 
                     with closing(file(cache_path + '.tmp', 'w')) as f:
@@ -80,6 +87,5 @@
                 else: rename(cache_path + '.tmp', cache_path)
         except IOError:
-            with closing(file(src_path)) as f:
-                ns.cfg = yaml.load(f, loader)
+            ns.cfg = load_master()
     return ns.cfg
 
