def inner(*args, **kwargs): tid = sem.acquire() if tid is None: raise TaskLockedException('unable to acquire lock: %s' % lock_name) try: return fn(*args, **kwargs) finally: sem.release(tid)
def __enter__(self): if not self._huey._put_if_empty(self._key, '1'): raise TaskLockedException('unable to set lock: %s' % self._name)
def __enter__(self): if not self._huey.put_if_empty(self._key, str(time.time())): raise TaskLockedException('unable to set lock: %s' % self._name)