X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=accounts.py;h=0a3509a2618352bb8c39592826f2ef65daee17e7;hb=160b13951491ecce6d79a41179fac9bd8c810fbb;hp=08ceac15738a0b4c8824ea7eb4a4c45258f37eb0;hpb=aa9e33baa88ec8ddb97468436c8c3972478e1b93;p=nodemanager.git diff --git a/accounts.py b/accounts.py index 08ceac1..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,9 +124,12 @@ class Worker: if not isinstance(self._acct, next_class): self._acct = next_class(rec) else: self._acct.configure(rec) if startingup: + csd_lock.acquire() global cumstartdelay - self._acct.start(delay=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()