X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=accounts.py;h=0a3509a2618352bb8c39592826f2ef65daee17e7;hb=160b13951491ecce6d79a41179fac9bd8c810fbb;hp=12084c266c1863802dc007bd31d2b7849f99161e;hpb=1218b7d0687156283b701f0cb15c920cf170df09;p=nodemanager.git diff --git a/accounts.py b/accounts.py index 12084c2..0a3509a 100644 --- a/accounts.py +++ b/accounts.py @@ -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 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()