diff --git a/lib/mcpu.py b/lib/mcpu.py index b657378ce9c42cd7422f3462104a8ab91186d46b..0cddbc6838e37203a56eec47d05765a666c1f764 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -229,6 +229,8 @@ class Processor(object): @param shared: Whether the locks should be acquired in shared mode @type timeout: None or float @param timeout: Timeout for acquiring the locks + @raise LockAcquireTimeout: In case locks couldn't be acquired in specified + amount of time """ if self._cbs: @@ -237,6 +239,9 @@ class Processor(object): acquired = self.context.glm.acquire(level, names, shared=shared, timeout=timeout, priority=priority) + if acquired is None: + raise LockAcquireTimeout() + return acquired def _ExecLU(self, lu): @@ -306,10 +311,6 @@ class Processor(object): acquired = self._AcquireLocks(level, needed_locks, share, calc_timeout(), priority) - - if acquired is None: - raise LockAcquireTimeout() - else: # Adding locks add_locks = lu.add_locks[level] @@ -374,11 +375,9 @@ class Processor(object): # Acquire the Big Ganeti Lock exclusively if this LU requires it, # and in a shared fashion otherwise (to prevent concurrent run with # an exclusive LU. - if self._AcquireLocks(locking.LEVEL_CLUSTER, locking.BGL, - not lu_class.REQ_BGL, calc_timeout(), - priority) is None: - raise LockAcquireTimeout() - + self._AcquireLocks(locking.LEVEL_CLUSTER, locking.BGL, + not lu_class.REQ_BGL, calc_timeout(), + priority) try: lu = lu_class(self, op, self.context, self.rpc) lu.ExpandNames()