indentation fixed
[nodemanager.git] / accounts.py
index 12084c2..47e7af5 100644 (file)
@@ -30,8 +30,9 @@ import tools
 
 
 # When this variable is true, start after any ensure_created
-startingup = False
-# Cumulative delay for starts when startingup is true
+Startingup = False
+# Cumulative delay for starts when Startingup is true
+csd_lock = threading.Lock()
 cumstartdelay = 0
 
 # shell path -> account class association
@@ -110,9 +111,9 @@ class Worker:
 
     def ensure_created(self, rec):
         """Cause the account specified by <rec> to exist if it doesn't already."""
-        self._q.put((self._ensure_created, rec.copy()))
+        self._q.put((self._ensure_created, rec.copy(), Startingup))
 
-    def _ensure_created(self, rec):
+    def _ensure_created(self, rec, startingup):
         curr_class = self._get_class()
         next_class = type_acct_class[rec['type']]
         if next_class != curr_class:
@@ -123,8 +124,12 @@ class Worker:
         if not isinstance(self._acct, next_class): self._acct = next_class(rec)
         else: self._acct.configure(rec)
         if startingup:
-            self._acct.start(delay=cumstartdelay)
+            csd_lock.acquire()
+            global cumstartdelay
+            delay = cumstartdelay
             cumstartdelay += 2
+            csd_lock.release()
+            self._acct.start(delay=delay)
         elif next_class != curr_class or self._acct.initscriptchanged:
             self._acct.start()
 
@@ -155,4 +160,5 @@ class Worker:
             try:
                 cmd = self._q.get()
                 cmd[0](*cmd[1:])
-            except: logger.log_exc()
+            except:
+                logger.log_exc(self.name)